Exemplo n.º 1
0
  @Override
  protected Object doExecute() throws PeerException {
    Peer peer = peerManager.getPeer(peerId);
    if (peer == null) {
      System.out.println("Peer not found.");
      return null;
    }
    final PeerResources limits =
        peer.getResourceLimits(new PeerId(peerManager.getLocalPeer().getId()));

    System.out.println(
        String.format(
            "%s, env:%d, cont:%d, net: %d",
            limits.getPeerId(),
            limits.getEnvironmentLimit(),
            limits.getContainerLimit(),
            limits.getNetworkLimit()));

    for (HostResources resources : limits.getHostResources()) {
      System.out.println(
          String.format(
              "\t%s, cpu: %s, ram:%s, disk:%s",
              resources.getHostId(),
              resources.getCpuLimit().getPrintValue(),
              resources.getRamLimit().getPrintValue(),
              resources.getDiskLimit().getPrintValue()));
    }
    return null;
  }
 @Before
 public void setUp() throws Exception {
   listener = spy(new CommandRequestListener());
   when(payload.getMessage(CommandRequest.class)).thenReturn(commandRequest);
   when(peerManager.getPeer(any(String.class))).thenReturn(sourcePeer);
   when(localPeer.bindHost(any(String.class))).thenReturn(host);
   doReturn(peerManager).when(listener).getPeerManager();
   doReturn(localPeer).when(peerManager).getLocalPeer();
 }