Example usage for java.rmi RemoteException RemoteException

List of usage examples for java.rmi RemoteException RemoteException

Introduction

In this page you can find the example usage for java.rmi RemoteException RemoteException.

Prototype

public RemoteException(String s, Throwable cause) 

Source Link

Document

Constructs a RemoteException with the specified detail message and cause.

Usage

From source file:edu.clemson.cs.nestbed.server.management.configuration.MoteManagerImpl.java

private MoteManagerImpl() throws RemoteException {
    super();/*from   w ww.  j a v a  2s .  c  o  m*/

    try {
        monitorLock = new ReentrantReadWriteLock(true);
        readLock = monitorLock.readLock();
        writeLock = monitorLock.writeLock();
        moteAdapter = AdapterFactory.createMoteAdapter(AdapterType.SQL);
        motes = moteAdapter.readMotes();

        log.debug("Motes read:\n" + motes);
    } catch (AdaptationException ex) {
        throw new RemoteException("AdaptationException", ex);
    } catch (Exception ex) {
        String msg = "Exception in MoteManagerImpl";
        log.error(msg, ex);
        throw new RemoteException(msg, ex);
    }
}

From source file:edu.clemson.cs.nestbed.server.management.profiling.NucleusManagerImpl.java

public long querySymbol(int id, String sourcePath, String moteType, String moteSerialID)
        throws RemoteException {
    long value = -1;

    try {/*w  w w. j a va  2  s  .c o m*/
        String device = "/dev/motes/" + moteSerialID;
        log.info("Query symbol on device: " + device);

        ProgramProfilingSymbol pps;
        ProgramSymbol programSymbol;
        String moduleName;
        String symbolName;

        pps = ProgramProfilingSymbolManagerImpl.getInstance().getProgramProfilingSymbol(id);
        programSymbol = ProgramSymbolManagerImpl.getInstance().getProgramSymbol(pps.getProgramSymbolID());
        moduleName = programSymbol.getModule();
        symbolName = programSymbol.getSymbol();

        if (!moduleName.equals("<global>")) {
            symbolName = moduleName + "." + symbolName;
        }

        String source = "serial@" + device + ":telos";
        PhoenixSource phoenix = BuildSource.makePhoenix(source, logMessenger);
        MoteIF moteIF = new MoteIF(phoenix);
        MemoryProfilingMessage payload = new MemoryProfilingMessage();
        MemoryProfilingMessageListener listener = new MemoryProfilingMessageListener();

        moteIF.registerListener(new MemoryProfilingMessage(), listener);

        payload.set_read((byte) 1);
        payload.set_offset((byte) 0);
        payload.set_address(programSymbol.getAddress());
        payload.set_size(programSymbol.getSize());

        moteIF.send(0, payload);

        value = listener.getValue();
        phoenix.shutdown();
    } catch (IOException ex) {
        String msg = "Exception in querySymbol";
        log.error(msg, ex);
        throw new RemoteException(msg, ex);
    }

    return value;
}

From source file:edu.clemson.cs.nestbed.server.management.configuration.ProjectManagerImpl.java

public void createNewProject(int testbedID, String name, String description) throws RemoteException {
    try {/*from w w  w.jav a 2  s  .  co m*/
        log.info("Request to create new Project:\n" + "  testbedID:    " + testbedID + "\n" + "  name:         "
                + name + "\n" + "  description:  " + description);

        Project project = projectAdapter.createProject(testbedID, name, description);

        writeLock.lock();
        try {
            projects.put(project.getID(), project);
        } finally {
            writeLock.unlock();
        }

        notifyObservers(Message.NEW_PROJECT, project);
    } catch (AdaptationException ex) {
        throw new RemoteException("AdaptationException", ex);
    } catch (Exception ex) {
        String msg = "Exception in createNewProject";
        log.error(msg, ex);
        throw new RemoteException(msg, ex);
    }
}

From source file:com.elasticgrid.platforms.ec2.EC2NodeInstantiatorImpl.java

public List<String> startInstances(String imageID, int minCount, int maxCount, List<String> groupSet,
        String userData, String keyName, boolean publicAddress, Object... options) throws RemoteException {
    if (StringUtils.isEmpty(imageID))
        throw new IllegalArgumentException("imageID can't be null");
    EC2NodeType instanceType = (EC2NodeType) options[0];
    logger.log(Level.FINER,/*w w w . j  a  va2  s. c  o  m*/
            "Starting {0} Amazon EC2 instance from image ''{1}'': keyName={2}, groups={3}, userdata={4}, instanceType={5}",
            new Object[] { minCount, imageID, keyName, groupSet, userData, instanceType });
    com.xerox.amazonws.ec2.InstanceType type;
    switch (instanceType) {
    case SMALL:
        type = com.xerox.amazonws.ec2.InstanceType.DEFAULT;
        break;
    case MEDIUM_HIGH_CPU:
        type = com.xerox.amazonws.ec2.InstanceType.MEDIUM_HCPU;
        break;
    case LARGE:
        type = com.xerox.amazonws.ec2.InstanceType.LARGE;
        break;
    case EXTRA_LARGE:
        type = com.xerox.amazonws.ec2.InstanceType.XLARGE;
        break;
    case EXTRA_LARGE_HIGH_CPU:
        type = com.xerox.amazonws.ec2.InstanceType.XLARGE_HCPU;
        break;
    default:
        throw new IllegalArgumentException(
                format("Invalid Amazon EC2 instance type '%s'", instanceType.getName()));
    }
    try {
        ReservationDescription reservation = jec2.runInstances(imageID, minCount, maxCount, groupSet, userData,
                keyName, type);
        List<ReservationDescription.Instance> instances = reservation.getInstances();
        ReservationDescription.Instance last = instances.get(instances.size() - 1);
        try {
            while (last.isPending()) {
                Thread.sleep(200);
                try {
                    reservation = jec2.describeInstances(Arrays.asList(last.getInstanceId())).get(0);
                    last = reservation.getInstances().get(instances.size() - 1);
                } catch (EC2Exception e) {
                    // do nothing -- sometimes EC2 don't allow us to request description of instance right after we start it!
                    logger.warning(format("Could not get instance description for instance '%s'. Retrying...",
                            last.getInstanceId()));
                }
            }
        } catch (InterruptedException e) {
            String message = format("Couldn't start properly %d Amazon EC2 instances."
                    + "Make sure instances of reservation ID %s are started and used properly within your cluster",
                    minCount, reservation.getReservationId());
            logger.log(Level.SEVERE, message, e);
            throw new RemoteException(message, e);
        }
        List<String> instancesIDs = new ArrayList<String>(instances.size());
        for (ReservationDescription.Instance instance : instances) {
            instancesIDs.add(instance.getInstanceId());
        }
        logger.log(Level.INFO, "Started {0} Amazon EC2 instance from image ''{1}''...",
                new Object[] { minCount, imageID });
        return instancesIDs;
    } catch (EC2Exception e) {
        throw new RemoteException("Can't start Amazon EC2 instances", e);
    }
}

From source file:edu.clemson.cs.nestbed.server.management.profiling.MoteMessageManager.java

public void removeMessageObserver(int pmsID, RemoteObserver observer) throws RemoteException {
    log.info("Removing a message observer for moteID: " + mote.getID() + " for message id: " + pmsID);

    ProgramMessageSymbol pms;// w w  w  .j a  va  2s  . c om
    List<RemoteObserver> observers;

    try {
        pms = ProgramMessageSymbolManagerImpl.getInstance().getProgramMessageSymbol(pmsID);
        observers = messageObserverListMap.get(pms);

        if (observers != null) {
            observers.remove(observer);
        }
    } catch (RemoteException ex) {
        throw ex;
    } catch (Exception ex) {
        String msg = "Exception in removeMessageObserver";
        log.error(msg, ex);
        throw new RemoteException(msg, ex);
    }
}

From source file:edu.clemson.cs.nestbed.server.management.configuration.ProgramSymbolManagerImpl.java

public ProgramSymbol deleteProgramSymbol(int id) throws RemoteException {
    try {/*from w ww  . j ava  2s  .  c o m*/
        log.debug("Request to delete program symbol with id: " + id);

        cleanupProgramProfilingSymbol(id);

        ProgramSymbol programSymbol = programSymbolAdapter.deleteProgramSymbol(id);

        writeLock.lock();
        try {
            programSymbols.remove(programSymbol.getID());
        } finally {
            writeLock.unlock();
        }

        notifyObservers(Message.DELETE_SYMBOL, programSymbol);

        return programSymbol;
    } catch (AdaptationException ex) {
        throw new RemoteException("AdaptationException", ex);
    } catch (RemoteException ex) {
        throw ex;
    } catch (Exception ex) {
        String msg = "Exception in deleteProgramSymbol";
        log.error(msg, ex);
        throw new RemoteException(msg, ex);
    }
}

From source file:edu.duke.cabig.c3pr.rules.deploy.RuleDeploymentServiceImpl.java

public void deregisterRuleSet(String bindUri) throws RemoteException {
    try {/*ww  w.j  a  va 2s.  com*/
        RuleServiceContext.getInstance().ruleAdministrator.deregisterRuleExecutionSet(bindUri, null);
    } catch (Exception e) {
        log.info("Error while undeploying rules", e);
        throw new RemoteException("Error while undeploying rules," + e.getMessage(), e);
    }

    rc.ruleSetDeployed(bindUri);
    rc.ruleSetModified(bindUri);

}

From source file:org.molgenis.wikipathways.client.WikiPathwaysRESTBindingStub.java

@Override
public WSSearchResult[] findPathwaysByText(String query, String species) throws RemoteException {
    try {//from   www.  j av  a2s.  c o m
        query = query.replace(" ", "+");
        String url = baseUrl + "/findPathwaysByText?query=" + query;
        if (species != null) {
            species = species.replace(" ", "+");
            url = url + "&species=" + species;
        }

        Document jdomDocument = Utils.connect(url, client);
        Element root = jdomDocument.getRootElement();
        List<Element> list = root.getChildren("result", WSNamespaces.NS1);
        WSSearchResult[] res = new WSSearchResult[list.size()];
        for (int i = 0; i < list.size(); i++) {
            res[i] = Utils.parseWSSearchResult(list.get(i));
        }
        return res;
    } catch (Exception e) {
        throw new RemoteException(e.getMessage(), e.getCause());
    }
}

From source file:edu.clemson.cs.nestbed.server.management.configuration.ProgramManagerImpl.java

public List<Program> getProgramList(int projectID) throws RemoteException {
    log.debug("getProgramList() called");
    List<Program> programList = new ArrayList<Program>();

    readLock.lock();//  ww w .ja va 2  s  .  co m
    try {
        for (Program i : programs.values()) {
            if (i.getProjectID() == projectID) {
                programList.add(i);
            }
        }
    } catch (Exception ex) {
        String msg = "Exception in getProgramList";
        log.error(msg, ex);
        throw new RemoteException(msg, ex);
    } finally {
        readLock.unlock();
    }

    return programList;
}

From source file:edu.clemson.cs.nestbed.server.management.configuration.MoteDeploymentConfigurationManagerImpl.java

public List<MoteDeploymentConfiguration> getMoteDeploymentConfigurations(int projDepConfID)
        throws RemoteException {
    List<MoteDeploymentConfiguration> mdcs;
    mdcs = new ArrayList<MoteDeploymentConfiguration>();

    readLock.lock();/*ww  w  .  j  ava 2  s  .  c o  m*/
    try {
        for (MoteDeploymentConfiguration i : moteDepConfigs.values()) {
            if (i.getProjectDeploymentConfigurationID() == projDepConfID) {
                mdcs.add(i);
            }
        }
    } catch (Exception ex) {
        String msg = "Exception in getMoteDeploymentConfigurations";
        log.error(msg, ex);
        throw new RemoteException(msg, ex);
    } finally {
        readLock.unlock();
    }

    return mdcs;
}