Examples of MobileComponentIDClientImpl


Examples of xcat.mobile.ccacore.MobileComponentIDClientImpl

      // Instantiate the component
      container.createComponentInstance(instanceName,
          componentHandle,
          className);     
      // Create an instance of the client side of XCATComponentID
      cid = new MobileComponentIDClientImpl(instanceName, componentHandle);
    } else
      throw new NonstandardException("Unknown componentType: " + componentType);

    // transfer the properties object to the component
    cid.setProperties(TypeUtil.toXML(properties));
View Full Code Here

Examples of xcat.mobile.ccacore.MobileComponentIDClientImpl

    // initialize XCATComponentIDClient with a null GSH
    XCATComponentID cid = null;
    if (componentType.equals("basic"))
      cid = new XCATComponentIDClientImpl(instanceName, null);
    else if (componentType.equals("mobile"))
      cid = new MobileComponentIDClientImpl(instanceName, null);
    else // shouldn't get here, since we have thrown this exception before
      throw new NonstandardException("Unknown componentType: " + componentType);

    // insert into the namedComponentIDs hashMap
    namedComponentIDs.put(instanceName, cid);
View Full Code Here

Examples of xcat.mobile.ccacore.MobileComponentIDClientImpl

    // initialize XCATComponentIDClient with a null GSH
    XCATComponentID cid = null;
    if (componentType.equals("basic"))
      cid = new XCATComponentIDClientImpl(instanceName, null);
    else if (componentType.equals("mobile"))
      cid = new MobileComponentIDClientImpl(instanceName, null);
    else // shouldn't get here, since we have thrown this exception before
      throw new NonstandardException("Unknown componentType: " + componentType);
   
    // insert into the namedComponentIDs hashMap
    namedComponentIDs.put(instanceName, cid);
View Full Code Here

Examples of xcat.mobile.ccacore.MobileComponentIDClientImpl

    // set up the edges
    for (int i = 0; i < componentInfo.length; i++) {
      String usesComponentName = componentInfo[i].getInstanceName();
      MobileComponentID cid =
  new MobileComponentIDClientImpl(usesComponentName,
          componentInfo[i].getInstanceHandle());
      String[] usesPortNames = cid.getUsedPortNames();

      // Add an edge for every uses port
      for (int j = 0; j < usesPortNames.length; j++) {
  logger.finest("Adding a connection for" +
          " uses component: " +
          usesComponentName +
          ", uses port: " +
          usesPortNames[j]);

  // Get the ConnectionID for this uses port
  XCATConnectionInfo connInfo = cid.getConnectionInfo(usesPortNames[j]);

  // If this port is not connected, skip to next iteration
  if (connInfo == null)
    continue;
View Full Code Here

Examples of xcat.mobile.ccacore.MobileComponentIDClientImpl

      throw new NonstandardException("Component " + providesComponentName +
             " not present in the graph");

    // retrieve componentIDs for the uses and provides side
    MobileComponentID userID =
      new MobileComponentIDClientImpl(usesComponentName,
              usesComponentHandle);
    MobileComponentID providerID =
      new MobileComponentIDClientImpl(providesComponentName,
              providesComponentHandle);
   
    // create a ConnectionID for this connection
    XCATConnectionID connID =
      new XCATConnectionIDImpl(providerID,
View Full Code Here

Examples of xcat.mobile.ccacore.MobileComponentIDClientImpl

      userID.confirmMigration(connID.getUserPortName());
    }
   
    // Freeze the execution of the component
    MobileComponentID cid =
      new MobileComponentIDClientImpl(cInfo.getInstanceName(),
              cInfo.getInstanceHandle());
    cid.freezeComponent(getGSH());
   
    // Wait till the component sends back a notification that it is frozen
    synchronized(mInfo) {
      if (!mInfo.getIsFrozen()) {
  try {
    mInfo.wait();
  } catch (InterruptedException ie) {
    logger.severe("Exception when waiting for migration to complete",
      ie);
    throw new NonstandardException("Exception when waiting for migration to complete",
           ie);
  }
      }
    }
   
    // decrement number of outstanding frozen components
    synchronized(this) {
      outstandingFrozenComps--;
    }

    // check if the above call was successful
    if (mInfo.getMigrationStatus() == AppCoordinatorCallback.EXCEPTION)
      throw new NonstandardException("Remote component threw exception while being frozen");

    // Store the individual component state into persistent storage
    MasterStorageService mss = (MasterStorageService)
      URLToReference.createReference(masterStorageServiceURL,
             MasterStorageService.class.getName());
    String individualStorageServiceURL = mss.getIndividualStorageServiceLocation();
    String storageID = cid.storeIndividualComponentState(individualStorageServiceURL);

    // destroy the remote component
    try {
      cid.destroy();
    } catch (Exception e) {
      logger.severe("Caught exception while trying to destroy component",
        e);
      throw new NonstandardException("Caught exception while trying to destroy component",
             e);
    }

    // create a new instance of the component at the specified location
    cInfo.setInstanceLocation(targetLocation);
    createComponentInstance(cInfo);

    // retrieve the state for the migrated component
    cid.loadComponentState(individualStorageServiceURL, storageID);

    // delete state from storage service
    IndividualStorageService iss = (IndividualStorageService)
      URLToReference.createReference(individualStorageServiceURL,
             IndividualStorageService.class.getName());
    iss.deleteState(storageID);

    // resume execution of the migrated component
    cid.resumeExecution();

    // set the isFrozen false to false
    mInfo.setIsFrozen(false);

    // send a notification that all connected components that migration is complete
View Full Code Here

Examples of xcat.mobile.ccacore.MobileComponentIDClientImpl

    long time0 = System.currentTimeMillis();
    Object[] componentList = componentMap.values().toArray();
    for (int i = 0; i < componentList.length; i++) {
      ComponentInfo cInfo = (ComponentInfo) componentList[i];
      MobileComponentID cid =
  new MobileComponentIDClientImpl(cInfo.getInstanceName(),
          cInfo.getInstanceHandle());
      cid.freezeComponent(getGSH());
    }
    long time1 = System.currentTimeMillis();
    logger.info("Freeze request: " + (time1 - time0));

    // wait till all components are frozen
    if (outstandingFrozenComps < componentList.length) {
      synchronized(this) {
  try {
    wait();
  } catch (InterruptedException ie) {
    logger.severe("Exception when waiting for component to be frozen",
      ie);
    throw new NonstandardException("Exception when waiting for component to be frozen",
           ie);
  }

  // set the number of outstanding frozen components to 0
  outstandingFrozenComps = 0;

  // check if the above call was successful
  if (checkpointStatus == AppCoordinatorCallback.EXCEPTION)
    throw new NonstandardException("Exception while freezing components");
      }
    }
    long time2 = System.currentTimeMillis();
    logger.info("Time for components to freeze: " + (time2 - time1));

    // send request to store the state of the components
    MasterStorageService mss = (MasterStorageService)
      URLToReference.createReference(masterStorageServiceURL,
             MasterStorageService.class.getName());
    for (int i = 0; i < componentList.length; i++) {
      String individualStorageServiceURL = mss.getIndividualStorageServiceLocation();
      ComponentInfo cInfo = (ComponentInfo) componentList[i];
      MobileComponentID cid =
  new MobileComponentIDClientImpl(cInfo.getInstanceName(),
          cInfo.getInstanceHandle());
      cid.appendStateToCheckpoint(individualStorageServiceURL, getGSH());
    }

    // wait till all components have stored their states
    if (numComponentsStateStored < componentList.length) {
      synchronized(this) {
  try {
    wait();
  } catch (InterruptedException ie) {
    logger.severe("Exception when waiting for components to store states",
      ie);
    throw new NonstandardException("Exception when waiting for components to store states",
           ie);
  }

  // set the number of outstanding frozen components to 0
  numComponentsStateStored = 0;

  // check if the above call was successful
  if (checkpointStatus == AppCoordinatorCallback.EXCEPTION)
    throw new NonstandardException("Exception while storing component state");
      }
    }
    long time3 = System.currentTimeMillis();
    logger.info("Storing checkpoints: " + (time3 - time2));

    // Atomically update locations of checkpoints in the database
    Hashtable oldCheckpointMap = checkpointMap;
    checkpointMap = tempCheckpointMap;
    tempCheckpointMap = new Hashtable();
    if (dburl != null) {
      // Commit component information into database
      Connection conn = null;
      try {
  // connect to the database
  conn = DriverManager.getConnection(dburl,
             dbuser,
             dbpasswd);
 
  // set autocommit to false so that all of the following is atomic
  conn.setAutoCommit(false);
      } catch (Exception e) {
  logger.severe("Error while connecting to database", e);
  throw new NonstandardException("Error while connecting to database", e);
      }

      try {
  // for every component, update the distributed_checkpoint_table
  for (int i = 0; i < componentList.length; i++) {
    ComponentInfo cInfo = (ComponentInfo) componentList[i];
    CheckpointInfo cpInfo =
      (CheckpointInfo) checkpointMap.get(cInfo.getInstanceName());

    // update the entry into the table
    // have to delete + insert since MySQL 4.0.x doesn't support
    // ON DUPLICATE KEY UPDATE
    String sqlStmt0 =
      "delete from distributed_checkpoint_table where " +
      "instance_handle = '" +  cInfo.getInstanceHandle() + "';";
    PreparedStatement stmt0 = conn.prepareStatement(sqlStmt0);
    stmt0.executeUpdate();

    String sqlStmt1 =
      "insert into distributed_checkpoint_table" +
      "(instance_handle, application_id, " +
      "individual_storage_service_url, " +
      "storage_id) values (" +
      "'" + cInfo.getInstanceHandle() + "', " +
      "'" + applicationID + "', " +
      "'" + cpInfo.getStorageServiceURL() + "', " +
      "'" + cpInfo.getStorageID() + "');";
    PreparedStatement stmt1 = conn.prepareStatement(sqlStmt1);
    stmt1.executeUpdate();
  }
   
  // commit all inserts
  conn.commit();
 
  // clean up
  conn.close();
      } catch (Exception e) {
  logger.severe("Error while trying to store checkpoint locations into database: " +
          " Trying to rollback", e);
 
  // try to rollback
  try {
    conn.rollback();
  } catch (Exception re) {
    logger.severe("Error while trying to store checkpoint locations into database: " +
      " Rollback failed", re);
    throw new NonstandardException("Error while trying to store checkpoint locations " +
           "into database: Rollback failed", re);
  }
 
  throw new NonstandardException("Error while trying to store checkpoint locations " +
               "into database: Rollback successful", e);
      }
    }

    // delete old checkpoints
    Object[] cpList = oldCheckpointMap.values().toArray();
    for (int i = 0; i < cpList.length; i++) {
      CheckpointInfo cpInfo = (CheckpointInfo) cpList[i];
      IndividualStorageService iss = (IndividualStorageService)
  URLToReference.createReference(cpInfo.getStorageServiceURL(),
               IndividualStorageService.class.getName());
      iss.deleteState(cpInfo.getStorageID());
    }

    long time4 = System.currentTimeMillis();
    logger.info("Committing checkpoints: " + (time4 - time3));

    // send a notification to components that checkpointing is complete
    for (int i = 0; i < componentList.length; i++) {
      ComponentInfo cInfo = (ComponentInfo) componentList[i];
      MobileComponentID cid =
  new MobileComponentIDClientImpl(cInfo.getInstanceName(),
          cInfo.getInstanceHandle());
      cid.unfreezeComponent();
    }
    long time5 = System.currentTimeMillis();
    logger.info("Unfreezing components: " + (time5 - time4));
  }
View Full Code Here

Examples of xcat.mobile.ccacore.MobileComponentIDClientImpl

    // destroy all the components, if they are still alive
    Object[] componentList = componentMap.values().toArray();
    for (int i = 0; i < componentList.length; i++) {
      ComponentInfo cInfo = (ComponentInfo) componentList[i];
      MobileComponentID cid =
  new MobileComponentIDClientImpl(cInfo.getInstanceName(),
          cInfo.getInstanceHandle());
      try {
  cid.destroy();
      } catch (Exception e) {
  logger.severe("Caught exception while trying to destroy component",
          e);
  // continue since the component may be dead already
      }
    }

    // instantiate all components again
    for (int i = 0; i < componentList.length; i++) {
      ComponentInfo cInfo = (ComponentInfo) componentList[i];
      createComponentInstance(cInfo);
    }

    // load the checkpointed state
    for (int i = 0; i < componentList.length; i++) {
      ComponentInfo cInfo = (ComponentInfo) componentList[i];
      CheckpointInfo cpInfo = (CheckpointInfo) checkpointMap.get(cInfo.getInstanceName());

      MobileComponentID cid =
  new MobileComponentIDClientImpl(cInfo.getInstanceName(),
          cInfo.getInstanceHandle());
      cid.loadComponentState(cpInfo.getStorageServiceURL(),
           cpInfo.getStorageID());
    }

    // tell all components to proceed
    for (int i = 0; i < componentList.length; i++) {
      ComponentInfo cInfo = (ComponentInfo) componentList[i];
      MobileComponentID cid =
  new MobileComponentIDClientImpl(cInfo.getInstanceName(),
          cInfo.getInstanceHandle());
      cid.resumeExecution();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.