Пример #1
0
 /* (non-Javadoc)
  */
 @Override
 public void putContainerDescription(ClientRemoteContainerReply crcReply)
     throws ServiceException {
   if (crcReply.getRemoteAddress() == null
       && crcReply.getRemoteOS() == null
       && crcReply.getRemotePerformance() == null
       && crcReply.getRemoteBenchmarkResult() == null) {
     // --- RemoteContainerRequest WAS NOT successful ----
     loadInfo.setNewContainerCanceled(crcReply.getRemoteContainerName());
   } else {
     Service.Slice[] slices = getAllSlices();
     broadcastPutContainerDescription(slices, crcReply);
   }
 }
Пример #2
0
  /**
   * This method defines the local field 'myCRCReply' which is an instance of
   * 'ClientRemoteContainerReply' and holds the information about Performance, BenchmarkResult,
   * Network-Addresses of this container-node.
   *
   * @param loadFile indicates if the local file should be used or not
   */
  private void setLocalCRCReply(boolean loadFile) {

    ClientRemoteContainerReply crcReply = null;
    //        if (loadFile == true) {
    //            // --- Load the Descriptions from the local file ----------------------------
    //            crcReply = loadCRCReply();
    //        }

    if (crcReply == null) {
      // --- Build the Descriptions from the running system -----------------------

      // --- Get infos about the network connection -----
      InetAddress currAddress = null;
      InetAddress addressLocal;
      InetAddress addressLocalAlt;
      String hostIP, hostName, port;

      try {
        currAddress = InetAddress.getByName(myContainer.getID().getAddress());
        addressLocal = InetAddress.getLocalHost();
        addressLocalAlt = InetAddress.getByName("127.0.0.1");
        if (currAddress.equals(addressLocalAlt)) {
          currAddress = addressLocal;
        }
      } catch (UnknownHostException e) {
        logger.error(e);
      }
      hostIP = currAddress.getHostAddress();
      hostName = currAddress.getHostName();
      port = myContainer.getID().getPort();

      // --- Define Platform-Info -----------------------
      PlatformAddress myPlatform = new PlatformAddress();
      myPlatform.setIp(hostIP);
      myPlatform.setUrl(hostName);
      myPlatform.setPort(Integer.parseInt(port));
      myPlatform.setHttp4mtp(myContainerMTPurl);

      // --- Set OS-Informations ------------------------
      OSInfo myOS = new OSInfo();
      myOS.setOs_name(System.getProperty("os.name"));
      myOS.setOs_version(System.getProperty("os.version"));
      myOS.setOs_arch(System.getProperty("os.arch"));

      // --- Set the Performance of machine -------------
      LoadMeasureSigar sys = LoadMeasureThread.getLoadCurrent();
      PlatformPerformance myPerformance = new PlatformPerformance();
      myPerformance.setCpu_vendor(sys.getVendor());
      myPerformance.setCpu_model(sys.getModel());
      myPerformance.setCpu_numberOf(sys.getTotalCpu());
      myPerformance.setCpu_speedMhz((int) sys.getMhz());
      myPerformance.setMemory_totalMB(
          (int) LoadUnits.bytes2(sys.getTotalMemory(), LoadUnits.CONVERT2_MEGA_BYTE));

      // --- Set the performance (Mflops) of the system -

      BenchmarkResult bench = new BenchmarkResult();
      bench.setBenchmarkValue(LoadMeasureThread.getCompositeBenchmarkValue());

      // --- Get the PID of this JVM --------------------
      String jvmPID = LoadMeasureThread.getLoadCurrentJVM().getJvmPID();
      // --- Finally define this local description ------
      crcReply = new ClientRemoteContainerReply();
      crcReply.setRemoteContainerName(myContainer.getID().getName());
      crcReply.setRemotePID(jvmPID);
      crcReply.setRemoteAddress(myPlatform);
      crcReply.setRemoteOS(myOS);
      crcReply.setRemotePerformance(myPerformance);
      crcReply.setRemoteBenchmarkResult(bench);
    }

    // --- Set the local value of the ClientRemoteContainerReply --------------------
    myCRCReply = crcReply;

    // --- Broadcast the ClientRemoteContainerReply-Object to all other container ---
    Service.Slice[] slices;
    try {
      slices = getAllSlices();
      broadcastPutContainerDescription(slices, myCRCReply);
    } catch (ServiceException e) {
      logger.error(e);
    }
  }