Java 类java.rmi.ConnectException 实例源码

项目:openNaEF    文件:ExceptionUtils.java   
public static ExternalServiceException getExternalServiceException(Exception e) {
    if (e instanceof ExternalServiceException) {
        return (ExternalServiceException) e;
    } else if (e instanceof RemoteException) {
        if (isLocalProblem((RemoteException) e)) {
            return new ExternalServiceException("Communication with the server could not be started.", e);
        }
        return new ExternalServiceException("An error occurred on the external server side.", e);
    } else if (e instanceof RuntimeException) {
        return new ExternalServiceException("An unexpected error occurred in the server. [" + e.getMessage() + "]", e);
    } else if (e instanceof HttpException) {
        return new ExternalServiceException("Unexpected error occurred in HTTP communication with external server. [" + e.getMessage() + "]", e);
    } else if (e instanceof ConnectException) {
        return new ExternalServiceException("Could not connect to external server. [" + e.getMessage() + "]", e);
    } else if (e instanceof IOException) {
        return new ExternalServiceException("An unexpected error occurred in the I / O with the external server. [" + e.getMessage() + "]", e);
    }
    return new ExternalServiceException("An unexpected error occurred. Response=[" + e.getMessage() + "]", e);
}
项目:Cross-JVM-Reflection    文件:JavaAgent.java   
public static void agentmain(String args, Instrumentation instrumentation) throws RemoteException {
    String name = null;
    for (String arg : args.split(",")) {
        if (arg.startsWith("name=")) {
            name = arg.replace("name=", "");
        }
    }
    if (name == null) {
        throw new IllegalArgumentException("The name to use for the rmi server was not provided as an argument to the java agent.");
    }
    Registry registry = LocateRegistry.getRegistry();
    if (registry != null) {
        DefaultServerImpl rmi = new DefaultServerImpl(ClassLoader.getSystemClassLoader());
        try {
            //Attempt to bind to the registry stub that was returned.
            registry.rebind(name, rmi);
        } catch (ConnectException ce) {
            //Couldn't bind to it (perhaps it doesn't exist), creating a new one.
            registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
            registry.rebind(name, rmi);
        }
    }
}
项目:javify    文件:UnicastRef.java   
/**
 * @deprecated
 */
public RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum,
                          long hash) throws RemoteException
{
  UnicastConnection conn;

  try
    {
      conn = manager.getConnection();
    }
  catch (IOException e1)
    {
      throw new ConnectException("connection failed to host: "
                                 + manager.serverName, e1);
    }

  // obj: useless?

  return (new UnicastRemoteCall(conn, objid, opnum, hash));
}
项目:jvm-stm    文件:UnicastRef.java   
/**
 * @deprecated
 */
public RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum,
                          long hash) throws RemoteException
{
  UnicastConnection conn;

  try
    {
      conn = manager.getConnection();
    }
  catch (IOException e1)
    {
      throw new ConnectException("connection failed to host: "
                                 + manager.serverName, e1);
    }

  // obj: useless?

  return (new UnicastRemoteCall(conn, objid, opnum, hash));
}
项目:incubator-taverna-server    文件:ForkRunFactory.java   
@Override
protected RemoteSingleRun getRealRun(UsernamePrincipal creator,
        Workflow workflow, UUID id) throws Exception {
    @Nonnull
    byte[] wf = serializeWorkflow(workflow);
    for (int i = 0; i < 3; i++) {
        initFactory();
        try {
            return getRealRun(creator, wf, id);
        } catch (ConnectException | ConnectIOException e) {
            // factory was lost; try to recreate
        }
        killFactory();
    }
    throw new NoCreateException("total failure to connect to factory "
            + factoryProcessName + "despite attempting restart");
}
项目:incubator-taverna-server    文件:IdAwareForkRunFactory.java   
@Override
protected RemoteSingleRun getRealRun(UsernamePrincipal creator,
        Workflow workflow, UUID id) throws Exception {
    byte[] wf = serializeWorkflow(workflow);
    String username = mapper == null ? null : mapper
            .getUsernameForPrincipal(creator);
    if (username == null)
        throw new Exception("cannot determine who to run workflow as; "
                + "local identity mapper returned null");
    for (int i = 0; i < 3; i++) {
        if (!factory.containsKey(username))
            initFactory(username);
        try {
            return getRealRun(creator, username, wf, id);
        } catch (ConnectException | ConnectIOException e) {
            // factory was lost; try to recreate
        }
        factory.remove(username);
    }
    throw new NoCreateException("total failure to connect to factory "
            + factoryProcessName + "despite attempting restart");
}
项目:Lucee    文件:CLIFactory.java   
@Override
public void run() {

    final String name = root.getAbsolutePath();
    InetAddress current = null;
    try {
        current = InetAddress.getLocalHost();
    } catch (final UnknownHostException e1) {
        e1.printStackTrace();
        return;
    }
    try {
        try {
            // first try to call existing service
            invoke(current, name);

        } catch (final ConnectException e) {
            startInvoker(name);
            invoke(current, name);
        }
    } catch (final Throwable t) {
        t.printStackTrace();
    }
}
项目:fourinone    文件:HbDaemo.java   
public void run()
{
    try{
        //System.out.println("heartbeat");
        String[] putarr = new String[putList.size()];
        putList.toArray(putarr);
        pk.heartbeat(putarr, sessionid);
    }catch(Exception e){
        //e.printStackTrace();
        LogUtil.info("[PutHbTask]", "[heartbeat:]", e.getMessage());
        //this.cancel();
        //HbDaemo.tm.cancel();
        if(e instanceof ConnectException){
            this.pk = pl.getNextLeader();
        }
    }
}
项目:JamVM-PH    文件:UnicastRef.java   
/**
 * @deprecated
 */
public RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum,
                          long hash) throws RemoteException
{
  UnicastConnection conn;

  try
    {
      conn = manager.getConnection();
    }
  catch (IOException e1)
    {
      throw new ConnectException("connection failed to host: "
                                 + manager.serverName, e1);
    }

  // obj: useless?

  return (new UnicastRemoteCall(conn, objid, opnum, hash));
}
项目:classpath    文件:UnicastRef.java   
/**
 * @deprecated
 */
public RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum,
                          long hash) throws RemoteException
{
  UnicastConnection conn;

  try
    {
      conn = manager.getConnection();
    }
  catch (IOException e1)
    {
      throw new ConnectException("connection failed to host: "
                                 + manager.serverName, e1);
    }

  // obj: useless?

  return (new UnicastRemoteCall(conn, objid, opnum, hash));
}
项目:freeVM    文件:ClientConnectionFactory.java   
static final AbstractClientConnection getClientConnection(Endpoint ep)
        throws IOException, UnknownHostException, ConnectException,
        ConnectIOException {
    Socket sock = null;
    AbstractClientConnection ret;

    RMIClientSocketFactory csf = (ep.getCsf() != null) ? ep.getCsf()
            : RMISocketFactory.getSocketFactory();
    if (csf == null) {
        csf = RMISocketFactory.getDefaultSocketFactory();
    }
    sock = csf.createSocket(ep.getEndpointID().getHost(), ep.getPort());
    if (SO_TIME_OUT != 0) {
        sock.setSoTimeout(SO_TIME_OUT);
    }
    sock.setTcpNoDelay(true);
    if (sock instanceof HttpSocketClientSide) {
        ret = new SingleOpClientConnection(sock, ep);
    } else {
        ret = new StreamClientConnection(sock, ep);
    }
    return ret;
}
项目:freeVM    文件:ClientConnectionFactory.java   
static final AbstractClientConnection getClientConnection(Endpoint ep)
        throws IOException, UnknownHostException, ConnectException,
        ConnectIOException {
    Socket sock = null;
    AbstractClientConnection ret;

    RMIClientSocketFactory csf = (ep.getCsf() != null) ? ep.getCsf()
            : RMISocketFactory.getSocketFactory();
    if (csf == null) {
        csf = RMISocketFactory.getDefaultSocketFactory();
    }
    sock = csf.createSocket(ep.getEndpointID().getHost(), ep.getPort());
    if (SO_TIME_OUT != 0) {
        sock.setSoTimeout(SO_TIME_OUT);
    }
    sock.setTcpNoDelay(true);
    if (sock instanceof HttpSocketClientSide) {
        ret = new SingleOpClientConnection(sock, ep);
    } else {
        ret = new StreamClientConnection(sock, ep);
    }
    return ret;
}
项目:Fourinone    文件:HbDaemo.java   
public void run()
{
    try{
        //System.out.println("heartbeat");
        String[] putarr = new String[putList.size()];
        putList.toArray(putarr);
        pk.heartbeat(putarr, sessionid);
    }catch(Exception e){
        //e.printStackTrace();
        LogUtil.info("[PutHbTask]", "[heartbeat:]", e.getMessage());
        //this.cancel();
        //HbDaemo.tm.cancel();
        if(e instanceof ConnectException){
            this.pk = pl.getNextLeader();
        }
    }
}
项目:openNaEF    文件:ExceptionUtils.java   
public static boolean isLocalProblem(RemoteException e) {
    if (e instanceof ConnectIOException) {
        return true;
    } else if (e instanceof ConnectException) {
        return true;
    } else if (e instanceof UnknownHostException) {
        return true;
    }
    return false;
}
项目:spring4-understanding    文件:SimpleRemoteSlsbInvokerInterceptorTests.java   
private void doTestInvokesMethodOnEjbInstanceWithConnectExceptionWithRefresh(
        boolean lookupHomeOnStartup, boolean cacheHome) throws Exception {

    final RemoteInterface ejb = mock(RemoteInterface.class);
    given(ejb.targetMethod()).willThrow(new ConnectException(""));

    int lookupCount = 2;
    if (!cacheHome) {
        lookupCount++;
        if (lookupHomeOnStartup) {
            lookupCount++;
        }
    }

    final String jndiName= "foobar";
    Context mockContext = mockContext(jndiName, ejb);

    SimpleRemoteSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);
    si.setRefreshHomeOnConnectFailure(true);
    si.setLookupHomeOnStartup(lookupHomeOnStartup);
    si.setCacheHome(cacheHome);

    RemoteInterface target = (RemoteInterface) configuredProxy(si, RemoteInterface.class);
    try {
        target.targetMethod();
        fail("Should have thrown RemoteException");
    }
    catch (ConnectException ex) {
        // expected
    }

    verify(mockContext, times(lookupCount)).close();
    verify(ejb, times(2)).remove();
}
项目:spring4-understanding    文件:ReflectionUtilsTests.java   
@Test
public void declaresException() throws Exception {
    Method remoteExMethod = A.class.getDeclaredMethod("foo", Integer.class);
    assertTrue(ReflectionUtils.declaresException(remoteExMethod, RemoteException.class));
    assertTrue(ReflectionUtils.declaresException(remoteExMethod, ConnectException.class));
    assertFalse(ReflectionUtils.declaresException(remoteExMethod, NoSuchMethodException.class));
    assertFalse(ReflectionUtils.declaresException(remoteExMethod, Exception.class));

    Method illegalExMethod = B.class.getDeclaredMethod("bar", String.class);
    assertTrue(ReflectionUtils.declaresException(illegalExMethod, IllegalArgumentException.class));
    assertTrue(ReflectionUtils.declaresException(illegalExMethod, NumberFormatException.class));
    assertFalse(ReflectionUtils.declaresException(illegalExMethod, IllegalStateException.class));
    assertFalse(ReflectionUtils.declaresException(illegalExMethod, Exception.class));
}
项目:paradox-nakadi-consumer    文件:HttpReactiveReceiverTest.java   
private Observable<HttpResponseChunk> emitChunksWithError(final int statusCode, final int restarts,
        final int events) {
    final AtomicInteger restartCounter = new AtomicInteger(0);
    return Observable.defer(() -> {
            final int restart = restartCounter.incrementAndGet();
            final Observable<HttpResponseChunk> chunks = emitRange(statusCode, restarts, events, restart);
            final Throwable t = restart % 2 == 0 ? new SocketTimeoutException("Test Socket timeout")
                                                 : new ConnectException("Test Connection failed");
            return Observable.concat(chunks, Observable.error(t));
        });
}
项目:xap-openspaces    文件:NetworkExceptionHelper.java   
public static boolean isConnectOrCloseException(Throwable e) {
    if (e instanceof ConnectException && 
        e.getCause() != null && 
        e.getCause() instanceof IOException) {

        if (e.getCause() instanceof ClosedChannelException || e.getCause() instanceof java.net.ConnectException) {
            return true;
        }

        if (e.getCause().getMessage() != null && e.getCause().getMessage().contains("aborted")) {
            return true;
        }

        if (e.getCause().getMessage() != null && e.getCause().getMessage().contains("Connection reset by peer")) {
            return true;
        }
    }
    if(e instanceof LRMINoSuchObjectException) {
        return true;
    }
    if (e instanceof IOException) {
        if (e.getMessage() != null && e.getMessage().startsWith("Connection reset by peer")) {
            return true;
        }
    }
    return false;
}
项目:GameServerFramework    文件:AbstractRMIServerClient.java   
/**
 * 创建建立 RMI 客户端 并连接
 *
 * @throws RemoteException
 *             远程异常
 * @throws NotBoundException
 *             未绑定异常
 */
private boolean createRMIClient() {

    // ready address and port
    String address = getServerConfig().getMasterAddress();
    int port = getServerConfig().getMasterPort();

    // try to connect
    try {
        logger.info("正在创建 RMI 客户端....");

        Registry masterRegistry = LocateRegistry.getRegistry(address, port,
                new SslRMIClientSocketFactory());

        _masterServer = (MasterRMIServerInterface) masterRegistry
                .lookup("MasterServer");
        _masterServer.ping();
        boolean success = _masterServer.registerServer(getServerConfig()
                .getServerKey(), _masterClientObj);
        if (!success) {
            logger.error("注册服务失败!...");
        } else {
            logger.info("已经成功注册上管理服务...");
            return true;
        }
    } catch (ConnectException connectException) {
        logger.error(" 尝试连接到     MasterServer  连接失败  :: ({}:{})[{}]", address,
                port, connectException.getMessage());
    } catch (RemoteException | NotBoundException ex) {
        logger.error("注册服务失败:", ex);
    }
    return false;
}
项目:incubator-taverna-server    文件:ForkRunFactory.java   
private RemoteRunFactory getRemoteFactoryHandle(String name)
        throws RemoteException, NotBoundException {
    log.info("about to look up resource called " + name);
    try {
        // Validate registry connection first
        getTheRegistry().list();
    } catch (ConnectException | ConnectIOException e) {
        log.warn("connection problems with registry", e);
    }
    RemoteRunFactory rrf = (RemoteRunFactory) getTheRegistry().lookup(name);
    log.info("successfully connected to factory subprocess "
            + factoryProcessName);
    return rrf;
}
项目:Lucee4    文件:CLIFactory.java   
@Override
public void run() {

    String name=root.getAbsolutePath();
    InetAddress current=null;
    try {
        current = InetAddress.getLocalHost();
    } catch (UnknownHostException e1) {
        e1.printStackTrace();
        return;
    }
    try {
        try {
            // first try to call existing service
            invoke(current,name);

        } 
        catch (ConnectException e) {
            startInvoker(name);
            invoke(current,name);
        }
    }
    catch (Throwable t) {
        if(t instanceof ThreadDeath) throw (ThreadDeath)t;
        t.printStackTrace();
    }
}
项目:fourinone    文件:ParkLeader.java   
protected Park electionLeader(int b, int i){
    Park pk = null;
    boolean thesarrok = true;
    i=i<groupserver.length?i:0;
    //b=b<0?groupserver.length-1:b;
    String[] sarr = groupserver[i];
    try{
        pk = (Park)BeanService.getBean(sarr[0],Integer.parseInt(sarr[1]),parkservicecfg);
        if(pk!=null)
            pk.askLeader();
    }catch(RemoteException re){
        LogUtil.info("electionLeader", "("+sarr[0]+":"+sarr[1]+"):", re.getMessage());
        thesarrok = false;
        if(re instanceof ConnectException){
            if(b!=i)//one cycle
            {
                b=!alwaystry&&b<0?i:b;
                pk = electionLeader(b,i+1);
            }
        }
    }catch(LeaderException le){
        //le.printStackTrace();
        LogUtil.info("[electionLeader]", "[LeaderException]", le.getMessage());
        thesarrok = false;
        String[] ls = le.getLeaderServer();
        int leaderindex = getLeaderIndex(ls);
        pk = electionLeader(-1,leaderindex);
    }
    if(thesarrok)
    {
        thisserver = sarr;
        LogUtil.info("", "", "leader server is("+thisserver[0]+":"+thisserver[1]+")");
    }
    return pk;
}
项目:fourinone    文件:ParkLeader.java   
protected Park electionLeader(int i){
    Park pk = null;
    boolean thesarrok = true;
    i=i<groupserver.length?i:0;
    String[] sarr = groupserver[i];
    try{
        pk = (Park)BeanService.getBean(sarr[0],Integer.parseInt(sarr[1]),parkservicecfg);
        if(pk!=null)
            pk.askLeader();
    }catch(RemoteException re){
        LogUtil.info("electionLeader", "("+sarr[0]+":"+sarr[1]+"):", re.getMessage());
        thesarrok = false;
        if(re instanceof ConnectException){
            pk = electionLeader(i+1);
        }
    }catch(LeaderException le){
        //le.printStackTrace();
        LogUtil.info("electionLeader", "LeaderException", le);
        thesarrok = false;
        String[] ls = le.getLeaderServer();
        int leaderindex = getLeaderIndex(ls);
        pk = electionLeader(leaderindex);
    }
    if(thesarrok)
    {
        thisserver = sarr;
        LogUtil.info("", "", "leader server is("+thisserver[0]+":"+thisserver[1]+")");
    }
    return pk;
}
项目:class-guard    文件:SimpleRemoteSlsbInvokerInterceptorTests.java   
private void doTestInvokesMethodOnEjbInstanceWithConnectExceptionWithRefresh(
        boolean lookupHomeOnStartup, boolean cacheHome) throws Exception {

    final RemoteInterface ejb = mock(RemoteInterface.class);
    given(ejb.targetMethod()).willThrow(new ConnectException(""));

    int lookupCount = 2;
    if (!cacheHome) {
        lookupCount++;
        if (lookupHomeOnStartup) {
            lookupCount++;
        }
    }

    final String jndiName= "foobar";
    Context mockContext = mockContext(jndiName, ejb);

    SimpleRemoteSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);
    si.setRefreshHomeOnConnectFailure(true);
    si.setLookupHomeOnStartup(lookupHomeOnStartup);
    si.setCacheHome(cacheHome);

    RemoteInterface target = (RemoteInterface) configuredProxy(si, RemoteInterface.class);
    try {
        target.targetMethod();
        fail("Should have thrown RemoteException");
    }
    catch (ConnectException ex) {
        // expected
    }

    verify(mockContext, times(lookupCount)).close();
    verify(ejb, times(2)).remove();
}
项目:class-guard    文件:ReflectionUtilsTests.java   
@Test
public void declaresException() throws Exception {
    Method remoteExMethod = A.class.getDeclaredMethod("foo", new Class[] { Integer.class });
    assertTrue(ReflectionUtils.declaresException(remoteExMethod, RemoteException.class));
    assertTrue(ReflectionUtils.declaresException(remoteExMethod, ConnectException.class));
    assertFalse(ReflectionUtils.declaresException(remoteExMethod, NoSuchMethodException.class));
    assertFalse(ReflectionUtils.declaresException(remoteExMethod, Exception.class));

    Method illegalExMethod = B.class.getDeclaredMethod("bar", new Class[] { String.class });
    assertTrue(ReflectionUtils.declaresException(illegalExMethod, IllegalArgumentException.class));
    assertTrue(ReflectionUtils.declaresException(illegalExMethod, NumberFormatException.class));
    assertFalse(ReflectionUtils.declaresException(illegalExMethod, IllegalStateException.class));
    assertFalse(ReflectionUtils.declaresException(illegalExMethod, Exception.class));
}
项目:cn1    文件:ClientConnection.java   
/**
 * Constructs ClientConnection, obtains input/output streams and acknowledge
 * protocol with server side.
 *
 * @param s Connected socket
 * @param ep server's endpoint
 *
 * @throws RemoteException if any I/O error occurred during connection
 *         creation
 */
public ClientConnection(Socket s, Endpoint ep) throws RemoteException {
    this.s = s;
    this.ep = ep;

    try {
        out = new BufferedOutputStream(s.getOutputStream());
        in = new BufferedInputStream(s.getInputStream());
    } catch (IOException ioe) {
        // rmi.40=Unable to establish connection to server
        throw new ConnectException(Messages.getString("rmi.40"), ioe); //$NON-NLS-1$
    }
    serverProtocolAck();
}
项目:cn1    文件:ConnectExceptionTest.java   
/**
 * {@link java.rmi.ConnectException#ConnectException(java.lang.String, java.lang.Exception)}.
 */
public void testConnectExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    ConnectException e = new ConnectException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
项目:cn1    文件:ConnectExceptionTest.java   
/**
 * {@link java.rmi.ConnectException#ConnectException(java.lang.String)}.
 */
public void testConnectExceptionString() {
    ConnectException e = new ConnectException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}
项目:cassandra-mesos-deprecated    文件:ServerHealthCheckTask.java   
private HealthCheckDetails doHealthCheck() {
    final HealthCheckDetails.Builder builder = HealthCheckDetails.newBuilder();

    if (jmxConnect == null) {
        return builder.setHealthy(false)
            .setMsg("no JMX connect to Cassandra process")
            .build();
    }

    try {
        final CassandraFrameworkProtos.NodeInfo info = buildInfo();
        builder.setHealthy(true)
            .setInfo(info);
        LOGGER.info("Healthcheck succeeded: operationMode:{} joined:{} gossip:{} native:{} rpc:{} uptime:{}s endpoint:{}, dc:{}, rack:{}, hostId:{}, version:{}",
            info.getOperationMode(),
            info.getJoined(),
            info.getGossipRunning(),
            info.getNativeTransportRunning(),
            info.getRpcServerRunning(),
            info.getUptimeMillis() / 1000,
            info.getEndpoint(),
            info.getDataCenter(),
            info.getRack(),
            info.getHostId(),
            info.getVersion());
    } catch (final Exception e) {
        //noinspection ThrowableResultOfMethodCallIgnored
        final ConnectException connectException = findConnectException(e);
        if (connectException != null) {
            LOGGER.info("Health check failed: {}", connectException.getMessage().replaceAll("\\n\\t", ""));
        } else {
            LOGGER.warn("Health check failed due to unexpected exception.", e);
            builder.setHealthy(false)
                .setMsg(e.toString());
        }
    }

    return builder.build();
}
项目:cassandra-mesos-deprecated    文件:ServerHealthCheckTask.java   
@Nullable
private static ConnectException findConnectException(@Nullable final Throwable t) {
    if (t == null) {
        return null;
    } else if (t instanceof ConnectException) {
        return (ConnectException) t;
    } else {
        return findConnectException(t.getCause());
    }
}
项目:freeVM    文件:ClientConnection.java   
/**
 * Constructs ClientConnection, obtains input/output streams and acknowledge
 * protocol with server side.
 *
 * @param s Connected socket
 * @param ep server's endpoint
 *
 * @throws RemoteException if any I/O error occurred during connection
 *         creation
 */
public ClientConnection(Socket s, Endpoint ep) throws RemoteException {
    this.s = s;
    this.ep = ep;

    try {
        out = new BufferedOutputStream(s.getOutputStream());
        in = new BufferedInputStream(s.getInputStream());
    } catch (IOException ioe) {
        // rmi.40=Unable to establish connection to server
        throw new ConnectException(Messages.getString("rmi.40"), ioe); //$NON-NLS-1$
    }
    serverProtocolAck();
}
项目:freeVM    文件:ConnectExceptionTest.java   
/**
 * {@link java.rmi.ConnectException#ConnectException(java.lang.String, java.lang.Exception)}.
 */
public void testConnectExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    ConnectException e = new ConnectException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
项目:freeVM    文件:ConnectExceptionTest.java   
/**
 * {@link java.rmi.ConnectException#ConnectException(java.lang.String)}.
 */
public void testConnectExceptionString() {
    ConnectException e = new ConnectException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}
项目:freeVM    文件:ConnectExceptionTest.java   
/**
 * {@link java.rmi.ConnectException#ConnectException(java.lang.String, java.lang.Exception)}.
 */
public void testConnectExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    ConnectException e = new ConnectException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
项目:freeVM    文件:ConnectExceptionTest.java   
/**
 * {@link java.rmi.ConnectException#ConnectException(java.lang.String)}.
 */
public void testConnectExceptionString() {
    ConnectException e = new ConnectException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}
项目:Fourinone    文件:ParkLeader.java   
protected Park electionLeader(int b, int i){
    Park pk = null;
    boolean thesarrok = true;
    i=i<groupserver.length?i:0;
    //b=b<0?groupserver.length-1:b;
    String[] sarr = groupserver[i];
    try{
        pk = (Park)BeanService.getBean(sarr[0],Integer.parseInt(sarr[1]),parkservicecfg);
        if(pk!=null)
            pk.askLeader();
    }catch(RemoteException re){
        LogUtil.info("electionLeader", "("+sarr[0]+":"+sarr[1]+"):", re.getMessage());
        thesarrok = false;
        if(re instanceof ConnectException){
            if(b!=i)//one cycle
            {
                b=!alwaystry&&b<0?i:b;
                pk = electionLeader(b,i+1);
            }
        }
    }catch(LeaderException le){
        //le.printStackTrace();
        LogUtil.info("[electionLeader]", "[LeaderException]", le.getMessage());
        thesarrok = false;
        String[] ls = le.getLeaderServer();
        int leaderindex = getLeaderIndex(ls);
        pk = electionLeader(-1,leaderindex);
    }
    if(thesarrok)
    {
        thisserver = sarr;
        LogUtil.info("", "", "leader server is("+thisserver[0]+":"+thisserver[1]+")");
    }
    return pk;
}
项目:Fourinone    文件:ParkLeader.java   
protected Park electionLeader(int i){
    Park pk = null;
    boolean thesarrok = true;
    i=i<groupserver.length?i:0;
    String[] sarr = groupserver[i];
    try{
        pk = (Park)BeanService.getBean(sarr[0],Integer.parseInt(sarr[1]),parkservicecfg);
        if(pk!=null)
            pk.askLeader();
    }catch(RemoteException re){
        LogUtil.info("electionLeader", "("+sarr[0]+":"+sarr[1]+"):", re.getMessage());
        thesarrok = false;
        if(re instanceof ConnectException){
            pk = electionLeader(i+1);
        }
    }catch(LeaderException le){
        //le.printStackTrace();
        LogUtil.info("electionLeader", "LeaderException", le);
        thesarrok = false;
        String[] ls = le.getLeaderServer();
        int leaderindex = getLeaderIndex(ls);
        pk = electionLeader(leaderindex);
    }
    if(thesarrok)
    {
        thisserver = sarr;
        LogUtil.info("", "", "leader server is("+thisserver[0]+":"+thisserver[1]+")");
    }
    return pk;
}
项目:jdk8u-jdk    文件:HandshakeTimeout.java   
public static void main(String[] args) throws Exception {

        System.setProperty("sun.rmi.transport.tcp.handshakeTimeout",
                           String.valueOf(TIMEOUT / 2));

        /*
         * Listen on port, but never process connections made to it.
         */
        ServerSocket serverSocket = new ServerSocket(PORT);

        /*
         * Attempt RMI call to port in separate thread.
         */
        Registry registry = LocateRegistry.getRegistry(PORT);
        Connector connector = new Connector(registry);
        Thread t = new Thread(connector);
        t.setDaemon(true);
        t.start();

        /*
         * Wait for call attempt to finished, and analyze result.
         */
        t.join(TIMEOUT);
        synchronized (connector) {
            if (connector.success) {
                throw new RuntimeException(
                    "TEST FAILED: remote call succeeded??");
            }
            if (connector.exception == null) {
                throw new RuntimeException(
                    "TEST FAILED: remote call did not time out");
            } else {
                System.err.println("remote call failed with exception:");
                connector.exception.printStackTrace();
                System.err.println();

                if (connector.exception instanceof MarshalException) {
                    System.err.println(
                        "TEST FAILED: MarshalException thrown, expecting " +
                        "java.rmi.ConnectException or ConnectIOException");
                } else if (connector.exception instanceof ConnectException ||
                           connector.exception instanceof ConnectIOException)
                {
                    System.err.println(
                        "TEST PASSED: java.rmi.ConnectException or " +
                        "ConnectIOException thrown");
                } else {
                    throw new RuntimeException(
                        "TEST FAILED: unexpected Exception thrown",
                        connector.exception);
                }
            }
        }
    }
项目:jdk8u-jdk    文件:HandshakeFailure.java   
public static void main(String[] args) throws Exception {

        /*
         * Listen on port...
         */
        ServerSocket serverSocket = new ServerSocket(PORT);

        /*
         * (Attempt RMI call to port in separate thread.)
         */
        Registry registry = LocateRegistry.getRegistry(PORT);
        Connector connector = new Connector(registry);
        Thread t = new Thread(connector);
        t.setDaemon(true);
        t.start();

        /*
         * ...accept one connection from port and send non-JRMP data.
         */
        Socket socket = serverSocket.accept();
        socket.getOutputStream().write("Wrong way".getBytes());
        socket.close();

        /*
         * Wait for call attempt to finish, and analyze result.
         */
        t.join(TIMEOUT);
        synchronized (connector) {
            if (connector.success) {
                throw new RuntimeException(
                    "TEST FAILED: remote call succeeded??");
            }
            if (connector.exception == null) {
                throw new RuntimeException(
                    "TEST FAILED: remote call did not time out");
            } else {
                System.err.println("remote call failed with exception:");
                connector.exception.printStackTrace();
                System.err.println();

                if (connector.exception instanceof MarshalException) {
                    System.err.println(
                        "TEST FAILED: MarshalException thrown, expecting " +
                        "java.rmi.ConnectException or ConnectIOException");
                } else if (connector.exception instanceof ConnectException ||
                           connector.exception instanceof ConnectIOException)
                {
                    System.err.println(
                        "TEST PASSED: java.rmi.ConnectException or " +
                        "ConnectIOException thrown");
                } else {
                    throw new RuntimeException(
                        "TEST FAILED: unexpected Exception thrown",
                        connector.exception);
                }
            }
        }
    }
项目:openjdk-jdk10    文件:HandshakeTimeout.java   
public static void main(String[] args) throws Exception {

        System.setProperty("sun.rmi.transport.tcp.handshakeTimeout",
                           String.valueOf(TIMEOUT / 2));

        /*
         * Listen on port, but never process connections made to it.
         */
        ServerSocket serverSocket = new ServerSocket(0);
        int port = serverSocket.getLocalPort();

        /*
         * Attempt RMI call to port in separate thread.
         */
        Registry registry = LocateRegistry.getRegistry(port);
        Connector connector = new Connector(registry);
        Thread t = new Thread(connector);
        t.setDaemon(true);
        t.start();

        /*
         * Wait for call attempt to finished, and analyze result.
         */
        t.join(TIMEOUT);
        synchronized (connector) {
            if (connector.success) {
                throw new RuntimeException(
                    "TEST FAILED: remote call succeeded??");
            }
            if (connector.exception == null) {
                throw new RuntimeException(
                    "TEST FAILED: remote call did not time out");
            } else {
                System.err.println("remote call failed with exception:");
                connector.exception.printStackTrace();
                System.err.println();

                if (connector.exception instanceof MarshalException) {
                    throw new RuntimeException(
                        "TEST FAILED: MarshalException thrown, expecting " +
                        "java.rmi.ConnectException or ConnectIOException");
                } else if (connector.exception instanceof ConnectException ||
                           connector.exception instanceof ConnectIOException)
                {
                    System.err.println(
                        "TEST PASSED: java.rmi.ConnectException or " +
                        "ConnectIOException thrown");
                } else {
                    throw new RuntimeException(
                        "TEST FAILED: unexpected Exception thrown",
                        connector.exception);
                }
            }
        }
    }