Example usage for java.rmi RemoteException printStackTrace

List of usage examples for java.rmi RemoteException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.objectweb.proactive.core.body.ft.protocols.cic.managers.FTManagerCIC.java

@Override
public synchronized int onSendReplyBefore(Reply reply) {
    if (multiactiveLogger.isDebugEnabled()) {
        multiactiveLogger.debug("#onSendReplyBefore " + reply.getMethodName());
    }//from  ww  w  .  jav  a 2  s  .  com
    // set message info values
    this.forSentReply.checkpointIndex = (char) this.checkpointIndex;
    this.forSentReply.historyIndex = (char) this.historyIndex;
    this.forSentReply.incarnation = (char) this.incarnation;
    this.forSentReply.lastRecovery = (char) this.lastRecovery;
    this.forSentReply.isOrphanFor = Character.MAX_VALUE;
    this.forSentReply.fromHalfBody = false;
    this.forSentReply.vectorClock = null;
    reply.setMessageInfo(this.forSentReply);

    // output commit
    if (FTManagerCIC.isOCEnable && this.isOutputCommit(reply)) {
        try {
            if (logger.isDebugEnabled()) {
                logger.debug(this.ownerID + " is output commiting for reply " + reply);
            }
            this.storage.outputCommit(this.forSentReply);
        } catch (RemoteException e) {
            logger.error("**ERROR** Cannot perform output commit");
            e.printStackTrace();
        }
    }

    return 0;
}

From source file:org.objectweb.proactive.core.body.ft.protocols.cic.managers.FTManagerCIC.java

@Override
public synchronized int onSendRequestBefore(Request request) {
    if (multiactiveLogger.isDebugEnabled()) {
        multiactiveLogger.debug("#onSendRequestBefore " + request.getMethodName());
    }/*  w ww.  j  a v a  2  s  .c o  m*/
    if (!request.getMethodName().equals(FTManager.CHECKPOINT_METHOD_NAME)) {
        // set message info values
        this.forSentRequest.checkpointIndex = (char) this.checkpointIndex;
        this.forSentRequest.historyIndex = (char) this.historyIndex;
        this.forSentRequest.incarnation = (char) this.incarnation;
        this.forSentRequest.lastRecovery = (char) this.lastRecovery;
        this.forSentRequest.isOrphanFor = Character.MAX_VALUE;
        this.forSentRequest.fromHalfBody = false;
        if (FTManagerCIC.isOCEnable) {
            this.forSentRequest.vectorClock = this.localVectorClock;
        }
        request.setMessageInfo(this.forSentRequest);

        // output commit
        if (FTManagerCIC.isOCEnable && this.isOutputCommit(request)) {
            try {
                if (logger.isDebugEnabled()) {
                    logger.debug(this.ownerID + " is output commiting for request " + request);
                }
                this.storage.outputCommit(this.forSentRequest);
            } catch (RemoteException e) {
                logger.error("**ERROR** Cannot perform output commit");
                e.printStackTrace();
            }
        }
    }
    return 0;
}

From source file:org.objectweb.proactive.core.body.ft.protocols.cic.managers.FTManagerCIC.java

@Override
public int beforeRestartAfterRecovery(CheckpointInfo ci, int inc) {
    CheckpointInfoCIC cic = (CheckpointInfoCIC) ci;
    BlockingRequestQueue queue = (owner).getRequestQueue();
    int index = cic.checkpointIndex;

    //   reinit ft values
    this.history = new Vector<UniqueID>();
    this.completingCheckpoint = false;
    this.lastCommitedIndex = cic.lastCommitedIndex;
    // historized requests are supposed to be "already received"
    this.deliveredRequestsCounter = cic.lastCommitedIndex; //cic.lastRcvdRequestIndex;
    // new history then begin at the end of the history of the checkpoint

    this.historyBaseIndex = cic.lastCommitedIndex + 1; //;cic.lastRcvdRequestIndex+1;

    // HERE, we need a proof that running in "histo mode" is equivalent that
    // running in normal mode from the end of the histo.
    this.awaitedRequests = new Vector<AwaitedRequest>();
    this.replyToResend = new Hashtable<Integer, Vector<ReplyLog>>();
    this.requestToResend = new Hashtable<Integer, Vector<RequestLog>>();
    this.checkpointIndex = index;
    this.nextMax = index;
    this.checkpointTimer = System.currentTimeMillis();
    this.historyIndex = index;
    this.lastRecovery = index;
    this.incarnation = inc;

    //add pending request to reuqestQueue
    Request pendingRequest = cic.pendingRequest;

    //pending request could be null with OOSPMD synchronization
    //and pending request is null when checkpoint is done through a request
    if (pendingRequest != null) {
        queue.addToFront(pendingRequest);
    }//from ww  w  .j  a v  a2 s.co  m

    //add orphan-tagged requests in request queue
    //this requests are also added to this.awaitedRequests
    this.filterQueue(queue, cic);

    // building history
    // System.out.println(""+ this.ownerID + " History size : " + cic.history.size());
    Iterator<UniqueID> itHistory = cic.history.iterator();
    while (itHistory.hasNext()) {
        UniqueID cur = itHistory.next();
        AwaitedRequest currentAwaitedRequest = new AwaitedRequest(cur);
        queue.add(currentAwaitedRequest);
        this.awaitedRequests.add(currentAwaitedRequest);
    }

    //enable communication
    //System.out.println("[CIC] enable communication");
    (owner).acceptCommunication();

    try {
        // update servers
        this.location.updateLocation(ownerID, owner.getRemoteAdapter());
        this.recovery.updateState(ownerID, RecoveryProcess.RUNNING);
    } catch (RemoteException e) {
        logger.error("Unable to connect with location server");
        e.printStackTrace();
    }

    // resend all in-transit message
    this.sendLogs((CheckpointInfoCIC) ci);

    return 0;
}

From source file:org.objectweb.proactive.core.body.ft.protocols.cic.managers.FTManagerCIC.java

@Override
public void updateLocationAtServer(UniqueID ownerID, UniversalBody remoteBodyAdapter) {
    try {//from  w  ww  . ja  v  a  2s  .  c om
        // update servers
        this.location.updateLocation(ownerID, remoteBodyAdapter);
        //            this.recovery.updateState(ownerID, RecoveryProcess.RUNNING);
    } catch (RemoteException e) {
        logger.error("Unable to connect with location server");
        e.printStackTrace();
    }
}

From source file:org.objectweb.proactive.core.body.ft.protocols.cic.managers.FTManagerCIC.java

@Override
public Checkpoint __checkpoint__(Request pendingRequest) {
    //stop accepting communication
    (owner).blockCommunication();/*w w w  . ja va2 s  .c  o  m*/
    nbEnqueuedCheckpoints.decrementAndGet();
    // synchronized on hisotry to avoid hisot commit during checkpoint
    synchronized (this.historyLock) {
        Checkpoint c;

        //long start;
        //long end;
        try {
            //start = System.currentTimeMillis();
            //System.out.println("BEGIN CHECKPOINT : used mem = " + this.getUsedMem() );
            synchronized (this) {
                if (logger.isDebugEnabled()) {
                    logger.debug("[CIC] Checkpointing with index = " + (this.checkpointIndex + 1));
                }

                // create infos for checkpoint
                CheckpointInfoCIC ci = new CheckpointInfoCIC();
                this.extendReplyLog(this.checkpointIndex + 1);
                this.extendRequestLog(this.checkpointIndex + 1);
                ci.replyToResend = (this.replyToResend.get(Integer.valueOf(this.checkpointIndex + 1)));
                ci.requestToResend = (this.requestToResend.get(Integer.valueOf(this.checkpointIndex + 1)));
                ci.pendingRequest = pendingRequest;
                ci.checkpointIndex = this.checkpointIndex + 1;

                // delete logs
                this.replyToResend.remove(Integer.valueOf(this.checkpointIndex + 1));
                this.requestToResend.remove(Integer.valueOf(this.checkpointIndex + 1));

                // inc checkpoint index
                this.checkpointIndex++;

                // Reset history only if OC is not possible
                if (!FTManagerCIC.isOCEnable) {
                    this.history = new Vector<UniqueID>();
                    this.historyBaseIndex = this.deliveredRequestsCounter + 1;
                    this.lastCommitedIndex = this.deliveredRequestsCounter;
                }

                // current informations must not be stored in the checkpoint
                Hashtable<Integer, Vector<RequestLog>> requestToSendTMP = this.requestToResend;
                this.requestToResend = null;
                Hashtable<Integer, Vector<ReplyLog>> replyToSendTMP = this.replyToResend;
                this.replyToResend = null;
                Vector<UniqueID> historyTMP = this.history;
                this.history = null;
                Vector<AwaitedRequest> awaitedRequestTMP = this.awaitedRequests;
                this.awaitedRequests = null;

                // record the next history base index
                ci.lastRcvdRequestIndex = this.deliveredRequestsCounter;
                // checkpoint the active object
                this.setCheckpointTag(true);
                c = new Checkpoint(owner, this.additionalCodebase);
                // add info to checkpoint
                c.setCheckpointInfo(ci);

                // send it to server
                this.storage.storeCheckpoint(c, this.incarnation);
                this.setCheckpointTag(false);

                // restore current informations
                this.replyToResend = replyToSendTMP;
                this.requestToResend = requestToSendTMP;
                this.history = historyTMP;
                this.awaitedRequests = awaitedRequestTMP;

                // this checkpoint has to be completed with its minimal hisotry
                this.completingCheckpoint = true;

                // reninit checkpoint values
                this.checkpointTimer = System.currentTimeMillis();
            }

            //end = System.currentTimeMillis();
            //System.out.println("[BENCH] Cumulated Ckpt time at " + this.checkpointIndex + " : " + this.cumulatedCheckpointTime + " ms");// + System.currentTimeMillis() + "]");
            //System.out.println("END CHECKPOINTING : used mem = " + this.getUsedMem());
            return c;
        } catch (RemoteException e) {
            logger.error("[CIC] Unable to send checkpoint to the server");
            e.printStackTrace();
        } finally {
            // allow communication
            (owner).acceptCommunication();
        }
        return null;
    }
}

From source file:org.objectweb.proactive.core.body.ft.protocols.cic.managers.FTManagerCIC.java

private HistoryUpdater commitHistories(int indexOfCkpt, long upTo, boolean sendToServer, boolean isMinimal) {
    synchronized (this.historyLock) {
        if (isMinimal && (this.historyIndex >= indexOfCkpt)) {
            // this minimal commit has already be performed
            // by a message reception : nothing to do
            return null;
        }// w  ww  .j  a v  a2 s.  c om

        // HISTO COMMIT
        List<UniqueID> histoToCommit = this.getHistoryToCommit(this.lastCommitedIndex + 1, upTo);

        // histo to commit could be null (ckpting during histo mode)
        HistoryUpdater toSend = null;
        if (histoToCommit == null) {
            // must send an empty histo to the server to commit the new recovery line !
            toSend = new HistoryUpdater(histoToCommit, 0, 0, this.ownerID, indexOfCkpt, this.incarnation);
            this.historyIndex = this.checkpointIndex;
            // last commited does not change
        } else {
            toSend = new HistoryUpdater(histoToCommit, this.lastCommitedIndex + 1, upTo, this.ownerID,
                    indexOfCkpt, this.incarnation);
            this.historyIndex = this.checkpointIndex;
            this.lastCommitedIndex = upTo;
            // delete commited history
            this.deleteCommitedHistory(toSend.base, toSend.last);
        }

        // send to the server if asked
        if (sendToServer) {
            try {
                this.storage.commitHistory(toSend);
            } catch (RemoteException e) {
                logger.error("[ERROR] Storage server is not reachable !");
                e.printStackTrace();
            }
        }
        return toSend;
    }
}

From source file:org.openadaptor.util.JVMNeutralMBeanServerFactory.java

/**
 * Use reflection to get an MBeanServer. Avoids compile issue where 1.4 jdk doesn't
 * have java.lang.management.ManagementFactory
 *
 * <pre>//from www.  j  a va  2 s. c o  m
 *
 * Note: For 1.4, an RMI registry may have to be manually started.
 * This may be achieved by something similar to ...
 * RJMX_LIB=<i>oa3_lib</i>
 * JMX_LIB=<i>oa3_lib</i>
 * CP=${RJMXLIB}/jmxremote.jar:${JMXLIB}/jmxri.jar
 * export CLASSPATH=.:$CP ; rmiregistry 51410 &
 *
 * Does <b>not</b> apply to 1.5+
 * </pre>
 * @return MBeanServer instance.
 */
public static MBeanServer getMBeanServer() {
    String jvmVersion = System.getProperties().getProperty("java.version");
    log.info("Getting MBeanServer [for jvm " + jvmVersion + "]");
    boolean isjvm1_4 = jvmVersion.startsWith("1.4.");
    String factory = isjvm1_4 ? FACTORY_1_4 : FACTORY_1_5;
    String method = isjvm1_4 ? METHOD_1_4 : METHOD_1_5;
    if (server == null) {
        server = getMBeanServer(factory, method);
        if (isjvm1_4) {
            //Todo: Add some kind of access mechanism to change the port!
            int port = DEFAULT_RMI_PORT;

            String serviceURLString = "service:jmx:rmi:///jndi/rmi://localhost:" + port + "/server";
            try {
                log.info("starting rmi registry on " + port);
                rmiRegistry = LocateRegistry.createRegistry(port);
                Runtime.getRuntime().addShutdownHook(new Thread() {
                    public void run() {
                    }
                });
            } catch (RemoteException e) {
                log.warn(e);
            }
            JMXServiceURL url;
            try {
                url = new JMXServiceURL(serviceURLString);
                //url = new JMXServiceURL("jmxmp", null, 5555);
                jmxConnectorServer_1_4 = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);

                // Start the RMI connector server
                log.info("Starting the RMI connector server");
                jmxConnectorServer_1_4.start();
                //Add a shutdownHook to make sure it stops also.
                addJMXShutdownHook();
                //ToDo: Remember to shut this baby down also!
                log.info("RMI connector server successfully started.");
                log.info("JMX clients may use the serviceURL: " + serviceURLString);

                //Start a Html Connection server - disabled for now.
                //It's just being explored.
                //startHtmlConnectorServer();
            } catch (Exception e) {
                log.warn("Failed to get RMI connector server started - " + e);
                e.printStackTrace();
            }
        }
    }
    return server;
}

From source file:org.opennms.protocols.vmware.VmwareCimQuery.java

private static void cimQuery(String hostname, String username, String password) {

    System.out.print("Trying to connect to " + hostname + "... ");

    VmwareViJavaAccess vmwareViJavaAccess = new VmwareViJavaAccess(hostname, username, password);

    try {/*w w w  .j  a  v a 2 s  . com*/
        vmwareViJavaAccess.connect();
    } catch (MalformedURLException e) {
        System.out.println("Exception:");
        e.printStackTrace();
        return;
    } catch (RemoteException e) {
        System.out.println("Exception:");
        e.printStackTrace();
        return;
    }

    System.out.println("Success!");

    ManagedEntity[] hostSystems;

    System.out.print(" Querying " + hostname + " for host systems... ");

    try {
        hostSystems = vmwareViJavaAccess.searchManagedEntities("HostSystem");
    } catch (RemoteException remoteException) {
        remoteException.printStackTrace();
        vmwareViJavaAccess.disconnect();
        return;
    }

    if (hostSystems != null) {
        System.out.println(hostSystems.length + " host system(s) found!");

        for (ManagedEntity managedEntity : hostSystems) {
            HostSystem hostSystem = (HostSystem) managedEntity;

            if (hostSystem.getSummary() != null) {
                if (hostSystem.getRuntime() != null) {
                    String powerState = hostSystem.getRuntime().getPowerState().toString();

                    if (!"poweredOn".equals(powerState)) {
                        System.out.println("  Ignoring host system " + hostSystem.getName() + " (powerState="
                                + powerState + ")... ");
                        continue;
                    } else {
                        System.out.print("  Determining primary Ip address of host system "
                                + hostSystem.getName() + " (powerState=" + powerState + ")... ");
                    }
                } else {
                    System.out.println(
                            "  Ignoring host system " + hostSystem.getName() + " (powerState=unknown)... ");
                    continue;
                }
            } else {
                System.out.println(
                        "  Ignoring host system " + hostSystem.getName() + " (powerState=unknown)... ");
                continue;
            }

            String ipAddress;

            try {
                ipAddress = vmwareViJavaAccess.getPrimaryHostSystemIpAddress(hostSystem);
            } catch (RemoteException remoteException) {
                System.out.println("Exception:");
                remoteException.printStackTrace();
                continue;
            }

            if (ipAddress != null) {
                System.out.print(ipAddress + "\n  Querying host system " + hostSystem.getName()
                        + " for numeric sensors... ");

                List<CIMObject> cimObjects;

                try {
                    cimObjects = vmwareViJavaAccess.queryCimObjects(hostSystem, "CIM_NumericSensor");
                } catch (Exception e) {
                    System.out.println("Exception:");
                    e.printStackTrace();
                    continue;
                }

                if (cimObjects != null) { // FIXME queryCimObjects returns an empty list or a filled list, but never null
                    System.out.println(cimObjects.size() + " sensor(s) found!");
                    for (CIMObject cimObject : cimObjects) {
                        String healthState = vmwareViJavaAccess.getPropertyOfCimObject(cimObject,
                                "HealthState");
                        String cimObjectName = vmwareViJavaAccess.getPropertyOfCimObject(cimObject, "Name");
                        System.out.print("   " + cimObjectName);

                        if (healthState != null) {
                            System.out.println(" " + m_healthStates.get(Integer.valueOf(healthState)));
                        } else {
                            System.out.println();
                        }
                    }
                } else {
                    System.out.println("NULL - aborting...");
                    continue;
                }
            } else {
                System.out.println("NULL - aborting...");
                continue;
            }
        }
    } else {
        System.out.println("NULL - aborting...");
    }

    System.out.println("Cleaning up...");

    vmwareViJavaAccess.disconnect();
}

From source file:org.transitime.applications.RmiQuery.java

/**
 * @param args//from   w  ww  . jav a 2 s  .c o m
 */
public static void main(String[] args) {
    processCommandLineOptions(args);

    try {
        if (command == Command.GET_PREDICTIONS) {
            getPredictions();
        } else if (command == Command.GET_VEHICLES) {
            getVehicles();
        } else if (command == Command.GET_ROUTE_CONFIG) {
            getRouteConfig();
        } else if (command == Command.GET_CONFIG) {
            getConfig();
        } else if (command == Command.GET_GTFS_RT_VEHICLES) {
            getGtfsRtVehiclesPositions();
        } else if (command == Command.GET_GTFS_RT_TRIPS) {
            getGtfsRtTripUpdates();
        } else if (command == Command.GET_ACTIVE_BLOCKS) {
            getActiveBlocks();
        }
    } catch (RemoteException e) {
        // Output stack trace as error message
        e.printStackTrace();
    }
}

From source file:org.ublog.benchmark.social.SocialBenchmark.java

@Override
public void initialize(Configuration conf) throws ConfigurationException {
    this.initialTweetsFactor = conf.getDouble("benchmark.social.initialTweetsFactor");

    Utils.MAX_MESSAGES_IN_TIMELINE = conf.getInt("benchmark.social.maximumMessagesTimeline");
    Utils.MaxNTweets = conf.getInt("benchmark.social.maximumTweetsPerUser");
    long seedNextOperation = conf.containsKey("benchmark.social.seedNextOperation")
            ? conf.getLong("benchmark.social.seedNextOperation")
            : System.nanoTime();//from  w  w w .  j  a v a  2 s  .c  o m
    long seedOwner = conf.containsKey("benchmark.social.seedOwner") ? conf.getLong("benchmark.social.seedOwner")
            : System.nanoTime();
    long seedTopic = conf.containsKey("benchmark.social.seedTopic") ? conf.getLong("benchmark.social.seedTopic")
            : System.nanoTime();
    long seedStartFollow = conf.containsKey("benchmark.social.seedStartFollow")
            ? conf.getLong("benchmark.social.seedStartFollow")
            : System.nanoTime();

    this.rndOp = new Random(seedNextOperation);
    this.rndOwner = new Random(seedOwner);
    this.rndTopic = new Random(seedTopic);
    this.rndStartFollow = new Random(seedStartFollow);

    this.probabilitySearchPerTopic = conf.getDouble("benchmark.social.probabilities.probabilitySearchPerTopic");
    this.probabilitySearchPerOwner = conf.getDouble("benchmark.social.probabilities.probabilitySearchPerOwner");
    this.probabilityGetRecentTweets = conf
            .getDouble("benchmark.social.probabilities.probabilityGetRecentTweets");
    this.probabilityGetFriendsTimeline = conf
            .getDouble("benchmark.social.probabilities.probabilityGetFriendsTimeline");
    this.probabilityStartFollowing = conf.getDouble("benchmark.social.probabilities.probabilityStartFollowing");
    this.probabilityStopFollowing = conf.getDouble("benchmark.social.probabilities.probabilityStopFollowing");
    if (this.probabilityGetFriendsTimeline + this.probabilityGetRecentTweets + this.probabilitySearchPerOwner
            + this.probabilitySearchPerTopic + this.probabilityStartFollowing
            + this.probabilityStopFollowing > 1) {
        logger.warn("The sum of all probabilities must be less or equal than 1.");
        throw new ConfigurationException("The sum of all probabilities must be less or equal than 1.");
    }

    String serverName = conf.getString("benchmark.server.name");
    int serverPort = conf.getInt("benchmark.server.port");
    this.remoteGraphServer = this.getRemoteGraphServer(serverName, serverPort);
    try {
        this.hasInitiated = this.remoteGraphServer.init(this.totalSize);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}