61 Matching Annotations
  1. Feb 2020
  2. ec2-18-220-227-92.us-east-2.compute.amazonaws.com ec2-18-220-227-92.us-east-2.compute.amazonaws.com
    1. Exercício
          @DisplayName("Test if the exception is thrown for not existing services")
          @Test
          void testServiceNotFoundExceptionThrown() {
              req= new APIRequest();
              assertThrows(ServiceNotFoundException.class,
                      ()->{
                              req.getContent("abc", "12");
                      });
          }
      
          @DisplayName("Test if the request returns null for not existing content")
          @Test
          void testRequestReturnsNull() throws ServiceNotFoundException {
              req= new APIRequest();
              String idService = req.addService(new APIMoodle());
              assertNull(req.getContent(idService, "12"));
          }
      
          @DisplayName("Test if the request returns the content previously added")
          @Test
          void testContentPreviouslyAdded() throws ServiceNotFoundException {
              req= new APIRequest();
              String idService = req.addService(new APIMoodle());
              String idContent = req.setContent(idService, "12");
              assertEquals(req.getContent(idService,idContent),"12");
          }
      
          @DisplayName("Test if the aggregated content of one service is returned correctly")
          @Test
          void testAggregatedContent() throws ServiceNotFoundException {
              req= new APIRequestContentAggregator();
              String idService = req.addService(new APIMoodle());
              req.setContent(idService, "Eu vou");
              req.setContent(idService, " a Viseu");
              req.setContent(idService, " estudar");
              assertEquals(req.getContent(idService,"0"),"Eu vou a Viseu estudar");
          }
      
  3. Dec 2019
    1. inimum frequencyand minimum cluster size are two parameters that significantly af-fect mining of navigation patterns

      cluster parameters

    2. Depth-first search (DFS) is an algorithmfor traversing or searching a graph. Starting from a vertexa, DFS in-duced byMis applied to search for the connected componentreachable from this vertex. Once the component has been found,the algorithm checks if there are any nodes that are not consideredin the visit.

      algorithm for traversing the graph

    3. In WebPUMTime ConnectivityandFrequencyare two strongindicators of the degree of connectivity for each pair of Web pages.

      Time Connectivity and frequency to measure relation between pages

    4. he clusteringmodel is build to find collection of related pages at a particularWeb site, relying on the visit-coherence assumption (Perkowitz &Etzioni, 2000a). The pages that a user visits during one interactionwith the site tend to be conceptually related.

      consider full pages without states?

    5. navigation pattern min-ing is performed on the derived user access sessions. The represen-tative user navigation pattern can be obtained by clusteringalgorithms

      clustering algorithms

    1. when it comes to your web browsing experience, it turns out that latency, not bandwidth, is likely the constraining factor today.
    2. Figure 1-1. In this data from StatCounter Global Stats, we can see that the total percentage of Internet traffic coming from mobile devices is steadily increasing.
    3. 75% of online shoppers who experience an issue such as a site freezing, crashing, taking too long to load, or having a convoluted checkout process will not buy from that site. Gomez studied online shopper behavior and found that 88% of online consumers are less likely to return to a site after a bad experience. The same study found that “at peak traffic times, more than 75% of online consumers left for a competitor’s site rather than suffer delays.”
    4. users expect pages to load in two seconds, and after three seconds, up to 40% of users will abandon your site. Moreover, 85% of mobile users expect sites to load at least as fast or faster than sites on their desktop.
    5. components of its user experience: layout, hierarchy, intuitiveness, ease of use, and more.
  4. Nov 2019
    1. UUID uuid = UUID.randomUUID();

      criação de um identificador UUID

    1. So what can we do? }Alternative? Synchronous models? BUT REAL, PRACTICAL SYSTEMS ARE NOT SYNCHRONUS !!! }Use randomization, probabilistic guarantees }Process groups: sacrifice liveness under the assumption that retransmissions will eventually be received from good participants, the protocol eventually terminates }Avoid consensus, use quorum systems

      resolução do problema de consenso em sistemas distribuídos assíncronos

    2. }Agreement: all non-faulty processes decide on the same value }Validity: if a process decides on a value, then there was a process that started with that value }Termination: A non-faulty process decides in a finite time

      propriedades de um algoritmo de consenso

    3. In an asynchronous system, a process pi cannot tell whether a non-responsive process pj has crashed or it is just slow

      o problema de consenso em sistemas assíncronos

    1. Technically, solving the asynchronous distributed consensus problem in bounded time is impossible. As proven by the Dijkstra Prize–winning FLP impossibility result [Fis85], no asynchronous distributed consensus algorithm can guarantee progress in the presence of an unreliable network.

      o problema de consenso em sistemas distribuídos assíncronos é impossível de resolver

    2. Distributed consensus algorithms may be crash-fail (which assumes that crashed nodes never return to the system) or crash-recover. Crash-recover algorithms are much more useful, because most problems in real systems are transient in nature due to a slow network, restarts, and so on. Algorithms may deal with Byzantine or non-Byzantine failures. Byzantine failure occurs when a process passes incorrect messages due to a bug or malicious activity, and are comparatively costly to handle, and less often encountered.

      modelos de falha considerados

    3. asynchronous distributed consensus, which applies to environments with potentially unbounded delays in message passing

      interesse apenas em sistemas assíncronos

    4. Network partitions are particularly challenging—a problem that appears to be caused by a full partition may instead be the result of: A very slow network Some, but not all, messages being dropped Throttle occurring in one direction, but not the other direction

      Porque é que as partições de rede criam condições de falha difíceis de diagnosticar

    5. The logic is intuitive: if two nodes can’t communicate (because the network is partitioned), then the system as a whole can either stop serving some or all requests at some or all nodes (thus reducing availability), or it can serve requests as usual, which results in inconsistent views of the data at each node.

      Resume a lógica do teorema CAP

    6. CAP Theorem

      Descreve propriedades fundamentais de um sistema distribuído.

    7. Which process is the leader of a group of processes? What is the set of processes in a group?

      questões importantes na gestão do grupo

    8. we find developers spend a significant fraction of their time building extremely complex and error-prone mechanisms to cope with eventual consistency and handle data that may be out of date. We think this is an unacceptable burden to place on developers and that consistency problems should be solved at the database level.

      A complexidade da eventual consistency pode inviabilizar a sua adoção

    9. Systems and software engineers are usually familiar with the traditional ACID datastore semantics (Atomicity, Consistency, Isolation, and Durability), but a growing number of distributed datastore technologies provide a different set of semantics known as BASE (Basically Available, Soft state, and Eventual consistency). Datastores that support BASE semantics have useful applications for certain kinds of data and can handle large volumes of data and transactions that would be much more costly, and perhaps altogether infeasible, with datastores that support ACID semantics.

      semânticas ACID e BASE

  5. Oct 2019
    1. Teste este serviço
      //...
      
      PlacesListInterface l1 = null;
      
               try{
                  System.out.println("Localizar servidor de Objetos...");         
                l1  = (PlacesListInterface) Naming.lookup("rmi://localhost:2022/placelist");
      
                  Place p = new Place("3510", "Viseu");
                  System.out.println("Invocar addPlace() ...");
                  l1.addPlace(p);
      
                  System.out.println("Obter o endereço do servidor no Registry() ...");
                  ObjectRegistryInterface l2;
                  PlacesListInterface l3;
                  try {
                      l2 = (ObjectRegistryInterface) Naming.lookup("rmi://localhost:2023/registry");
                      String addr = l2.resolve("3510");
      
                      System.out.println("Invocar getPlace() no servidor de objetos...");
                      l3  = (PlacesListInterface) Naming.lookup(addr);
                      System.out.println(l3.getPlace("3510").getLocality()));
                  } catch (MalformedURLException | NotBoundException e) {
                      e.printStackTrace();
                  }
      
              } catch(Exception e) { e.printStackTrace(); }
      
  6. Apr 2019
    1. - implemente as classes.

      AdicionaEncomenda

       Utilizador u = new Utilizador("Manuel","Ativo");
              PropostaAquisicao propostaAquisicao = new PropostaAquisicao(LocalDate.now(),u, "Alice no Pais das Maravilhas");
              Livro l = new Livro("Programar em Java", "FCA");
              RequisicaoCompraCopia requisicaoCompraCopia = new RequisicaoCompraCopia("pendente", LocalDate.now(), "Oficio",l,u);
              Encomenda encomenda = new Encomenda(LocalDate.now(),requisicaoCompraCopia);
              repo.adicionaEncomenda(encomenda);
      

      EntradaNovoLivro

      Utilizador u = new Utilizador("Manuel","Ativo");
              PropostaAquisicao propostaAquisicao = new PropostaAquisicao(LocalDate.now(),u,"Alice no Pais das Maravilhas");
              Livro l = new Livro("Programar em Java", "FCA");
              Copia c = new Copia(1, l);
              RequisicaoCompraCopia requisicaoCompraCopia = new RequisicaoCompraCopia("pendente", LocalDate.now(), "Oficio",l,u);
              Encomenda encomenda = new Encomenda(LocalDate.now(),requisicaoCompraCopia);
              EntradaNovoLivro entradaNovoLivro = new EntradaNovoLivro(LocalDate.now(),encomenda,c);
              repo.adicionaEntradaNovoLivro(entradaNovoLivro);
      
  7. Mar 2019
    1. construtor da classe Singleton() é privado

      //devolve true se o construtor for Public Modifier.isPublic(Registry.class.getDeclaredConstructor().getModifiers()

    1. Aplique o padrão Bridge a um componente

      Testar APIRequest

      APIRequest req= new APIRequest();
      String idService = req.addService(new APIMoodle());
      String idContent = req.setContent(idService, "12");
              System.out.println(req.getContent(idService,idContent));
      

      Testar APIRequestContentAggregator

      APIRequestContentAggregator req= new APIRequestContentAggregator();
      String idService = req.addService(new APIMoodle());
      req.setContent(idService, "Eu vou");
      req.setContent(idService, " a Viseu");
      req.setContent(idService, " estudar");
      System.out.println(req.getContent(idService,"0"));
      
  8. Feb 2019
    1. Aplique o padrão Composite

      Código para testar o padrão com um menu de 3 níveis

      SubMenu m = new SubMenu();
      m.setLabel("Inserir");
      
      SubMenu client = new SubMenu();
      client.setLabel("Cliente");
      m.addChild(client);
      
      Link enterprise = new Link();
      enterprise.setLabel("Empresarial");
      
      enterprise.setURL("http://www.abc.pt/empresarial");
      client.addChild(enterprise);
      
      SubMenu particular = new SubMenu();
      particular.setLabel("Particular");
      client.addChild(particular);
      
      Link withVat = new Link();
      withVat.setLabel("Particular com contribuinte");
      withVat.setURL("http://www.abc.pt/pcc");
      particular.addChild(withVat);
      
      m.showOptions();
      
  9. Oct 2018
    1. Submeta os projetos
      static Thread t1;
      
      t1 = (new Thread() {
                  public void run(){
                      RMIRegistry.main(new String[0]);
                      RMIReplicaManager.main(new String[0]);              
                      RMIServer.main(new String[]{"2028"});
                      RMIServer.main(new String[]{"2030"});
                      RMIServer.main(new String[]{"2029"});
                  }});
              t1.start();
      
              Thread.sleep(1000);
      
          PlacesListManagerInterface plm;
          PlacesListManagerInterface plmret;
          PlacesListInterface pli;
          ObjectRegistryInterface ori;
      
      
          try{
              System.out.println("SE DER ERROS DE CONCORRÊNCIA, É NECESSÁRIO TENTAR OUTRA VEZ!!!");
              System.out.println("Localizar ReplicaManager...");
              plm  = (PlacesListManagerInterface) Naming.lookup("rmi://localhost:2024/replicamanager");
              Thread.sleep(1000);
              Place p1 = new Place("3510", "Viseu");
              System.out.println("Invocar addPlace() no ReplicaManager para 3510...");
              plm.addPlace(p1);
      
              Place p2 = new Place("1000", "Lisboa");
              System.out.println("Invocar addPlace() no ReplicaManager para 1000...");
              plm.addPlace(p2);
      
              Place p3 = new Place("4000", "Lisboa");
              System.out.println("Invocar addPlace() no ReplicaManager para 4000...");
              plm.addPlace(p3);
      
              System.out.println("Obter o endereço do ReplicaManager no Registry() para o ObjectID 1000 ...");
              ori = (ObjectRegistryInterface) Naming.lookup("rmi://localhost:2023/registry");
              String addrRM = ori.resolve("1000");
      
              System.out.println("Destruir uma das réplicas ...");
              LocateRegistry.getRegistry(2029).unbind("placelist");
              Thread.sleep(2000);
      
      
              System.out.println("Pedir ao ReplicaManager para devolver um PlaceManager para o ObjectID 1000 ...");
              plm = (PlacesListManagerInterface) Naming.lookup(addrRM);
              boolean pl1done = false;
              boolean pl2done = false;
              boolean pl3done = false;
              String plAddress = null;
              for(int i=0; i<10 ; i++) {
                  plAddress = plm.getPlaceListAddress("1000");
                  invokeGetPlacePlaceManager(plAddress);
                  System.out.println("\tPara o Endereço " + plAddress);
                  if(plAddress.equals("rmi://localhost:2028/placelist")) pl1done=true;
                  else if(plAddress.equals("rmi://localhost:2029/placelist")) pl2done=true;
                       else if(plAddress.equals("rmi://localhost:2030/placelist")) pl3done=true;
              } 
      
              if(!(pl1done==pl2done==pl3done==true)) fail("Não está a devolver um PlaceManager aleatório...");
      
          } catch(Exception e) {
              e.printStackTrace();
              fail("Erro\n" + e.getMessage()); }
      }
      
      private void invokeGetPlacePlaceManager(String plAddress)
              throws NotBoundException, MalformedURLException, RemoteException {
          PlacesListInterface pli;
          System.out.println("Invocar getPlace() no PlaceManager");
          pli  = (PlacesListInterface) Naming.lookup(plAddress);
          String locality = pli.getPlace("1000").getLocality();
      
          System.out.println("\tDevolveu " + locality);
          assertEquals("Lisboa", locality);
      }
      
    1. validação
              t = (new Thread() {
                  public void run() {
                      RMIRegistry.main(new String[0]);
                      RMIReplicaManager.main(new String[0]);
                      RMIServer.main(new String[]{"2028"});
                      RMIServer.main(new String[]{"2029"});
                      RMIServer.main(new String[]{"2030"});
                      }
                      });
              t.start();
      
              Thread.sleep(1000);
      
          PlacesListManagerInterface plm;
          PlacesListManagerInterface plmret;
          PlacesListInterface pli;
          ObjectRegistryInterface ori;
      
      
          try{
              System.out.println("Localizar ReplicaManager...");
              plm  = (PlacesListManagerInterface) Naming.lookup("rmi://localhost:2024/replicamanager");
      
              Place p1 = new Place("3510", "Viseu");
              System.out.println("Invocar addPlace() no ReplicaManager para 3510...");
              plm.addPlace(p1);
      
              Place p2 = new Place("1000", "Lisboa");
              System.out.println("Invocar addPlace() no ReplicaManager para 1000...");
              plm.addPlace(p2);
      
              Place p3 = new Place("4000", "Lisboa");
              System.out.println("Invocar addPlace() no ReplicaManager para 4000...");
              plm.addPlace(p3);
      
              System.out.println("Obter o endereço do ReplicaManager no Registry() para o ObjectID 1000 ...");
              ori = (ObjectRegistryInterface) Naming.lookup("rmi://localhost:2023/registry");
              String addrRM = ori.resolve("1000");
      
              System.out.println("Pedir ao ReplicaManager para devolver um PlaceManager para o ObjectID 1000 ...");
              plm = (PlacesListManagerInterface) Naming.lookup(addrRM);
              boolean pl1done = false;
              boolean pl2done = false;
              boolean pl3done = false;
              String plAddress = null;
              for(int i=0; i<10 ; i++) {
                  plAddress = plm.getPlaceListAddress("1000");
                  System.out.println("\tDevolveu " + plAddress);
                  if(plAddress.equals("rmi://localhost:2028/placelist")) pl1done=true;
                  else if(plAddress.equals("rmi://localhost:2029/placelist")) pl2done=true;
                       else if(plAddress.equals("rmi://localhost:2030/placelist")) pl3done=true;
              } 
      
              if(!(pl1done==pl2done==pl3done==true)) fail("Não está a devolver um PlaceManager aleatório...");        
      
              System.out.println("Invocar getPlace() no PlaceManager");
              pli  = (PlacesListInterface) Naming.lookup(plAddress);
              String locality = pli.getPlace("1000").getLocality();
      
              System.out.println("\tDevolveu " + locality);
              assertEquals("Lisboa", locality);
      
      
          } catch(Exception e) { }
      }
      
  10. Sep 2018
    1. <xs:element ref="grupo"/>

      se for necessário incluir um grupo dentro de outro

    2. Crie o Schema
    3. maxOccurs="unbounded"

      não existe limite máximo para a escolha

    4. minOccurs="1"

      obriga a fazer pelo menos uma escolha

    1. mixed="true"

      O conteúdo do elemento email pode ter texto com elementos misturados dentro do mesmo, tal como aparece no XML anterior.

    1. xsd:element name="Product"

      Como o Product tem outros elementos dentro dele, não vai ter um atributo type="....". Em vez disso, contém um complexType que define os elementos interiores do Product.

    2. xsi:noNamespaceSchemaLocation="Produto.xsd"

      Indica que este ficheiro XML é validado pelo ficheiro Produto.xsd

    3. xsd:attribute name="ProductID"

      Um atributo é sempre declarado dentro do complexType, mas fora da sequência

    4. o elemento sequence

      Apesar de ter outras alternativas, o elemento sequence aparece quase sempre dentro do complexType. Dentro desta sequence estão os elementos interiores do Product.

    1. <N>,<Mensagem enviada pelo cliente>

      Split da String

      String stringComVirgulas="1,xxxx";

      stringComVirgulas.split(",")[0] -- Devolve "1" stringComVirgulas.split(",")[1] -- Devolve "0"

    2. aSocket.receive(request);

      o servidor bloqueia aqui à espera de um pedido do cliente

    3. new String(reply.getData())

      conversão do array de bytes enviado pelo servidor para String, de forma a que possa ser visualizado na consola

    4. aSocket.receive(reply);

      o cliente bloqueia aqui à espera da resposta do servidor

    5. new DatagramPacket(buffer, buffer.length)

      criação do datagrama que vai receber os dados do servidor

    6. byte[] buffer = new byte[1000];

      criação de um buffer para colocar a resposta do servidor

    7. aSocket.send(request);

      envio do datagrama através do socket

    8. DatagramPacket(m,  m.length, aHost, serverPort)

      datagrama com a mensagem a enviar para o servidor

    9. 6789

      porto do servidor

    10. InetAddress.getByName("localhost")

      objeto que representa o endereço do servidor para onde vamos enviar a mensagem

    11. getBytes()

      a mensagem tem de ser convertida para array de bytes antes de ser enviada

    12. DatagramSocket()

      criação do socket de comunicação

    13. erros de checksum

      checksums errados dão origem a mensagens descartadas

    14. checksums
    1. pe

      prefixo que representa o nome do namespace

    2. http://www.ipv.pt/documentos/pessoa

      nome do namespace

    3. documento

      elemento raiz