本文整理汇总了Java中java.rmi.ConnectIOException类的典型用法代码示例。如果您正苦于以下问题:Java ConnectIOException类的具体用法?Java ConnectIOException怎么用?Java ConnectIOException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectIOException类属于java.rmi包,在下文中一共展示了ConnectIOException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRealRun
import java.rmi.ConnectIOException; //导入依赖的package包/类
@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");
}
示例2: getRealRun
import java.rmi.ConnectIOException; //导入依赖的package包/类
@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");
}
示例3: RmiTransport
import java.rmi.ConnectIOException; //导入依赖的package包/类
public RmiTransport(ClientMonitor clientMonitor, ScheduledExecutorService executorService, ConnectionPinger connectionPinger, SocketDetails addr) throws ConnectionException {
super(clientMonitor, executorService, connectionPinger, RmiTransport.class.getClassLoader());
url = "rmi://" + addr.getHostName() + ":" + addr.getPort() + "/" + RmiInvoker.class.getName();
try {
rmiInvoker = (RmiInvoker) Naming.lookup(url);
} catch (NotBoundException nbe) {
throw new ConnectionException("Cannot bind to the remote RMI service. Either an IP or RMI issue.");
} catch (MalformedURLException mfue) {
throw new ConnectionException("Malformed URL, host/port (" + addr.getHostName() + "/" + addr.getPort() + ") must be wrong: " + mfue.getMessage());
} catch (ConnectIOException cioe) {
throw new ConnectionException("Cannot connect to remote RMI server. " + "It is possible that transport mismatch", cioe);
} catch (RemoteException re) {
throw new ConnectionException("Unknown Remote Exception : " + re.getMessage());
}
}
示例4: writeHeader
import java.rmi.ConnectIOException; //导入依赖的package包/类
/**
* Writes RMI protocol header and RMI protocol version to the open
* OutputStream.
*
* @param dout DataOutputStream to write header to
*
* @throws RemoteException if any I/O error occurred while writing header
*/
protected void writeHeader(DataOutputStream dout) throws RemoteException {
try {
dout.writeInt(RMI_HEADER);
dout.writeShort(PROTOCOL_VER);
} catch (IOException ioe) {
// rmi.41=Unable to write RMI protocol header
throw new ConnectIOException(Messages.getString("rmi.41"), ioe); //$NON-NLS-1$
}
if (transportLog.isLoggable(RMILog.VERBOSE)) {
// rmi.log.94=Using protocol version {0}
transportLog.log(RMILog.VERBOSE, Messages.getString("rmi.log.94", //$NON-NLS-1$
PROTOCOL_VER));
}
}
示例5: createSocket
import java.rmi.ConnectIOException; //导入依赖的package包/类
/**
* Creates and returns socket.
*
* @return created socket
*/
public Socket createSocket() throws RemoteException {
Socket s;
try {
s = DefaultRMISocketFactory.getNonNullClientFactory(csf)
.createSocket(host, port);
} catch (java.net.UnknownHostException uhe) {
// rmi.80=Unable to connect to server {0}
throw new java.rmi.UnknownHostException(
Messages.getString("rmi.80", toString()), uhe); //$NON-NLS-1$
} catch (java.net.ConnectException ce) {
throw new java.rmi.ConnectException(
Messages.getString("rmi.80", toString()), ce); //$NON-NLS-1$
} catch (IOException ioe) {
throw new ConnectIOException(
Messages.getString("rmi.80", toString()), ioe); //$NON-NLS-1$
}
return s;
}
示例6: AbstractClientConnection
import java.rmi.ConnectIOException; //导入依赖的package包/类
/**
* Creates a new connection to the specified
* {@link org.apache.harmony.rmi.internal.transport.Endpoint} using the underlying
* {@link java.net.Socket}
*
* @param sock
* the {@link java.net.Socket} to which the connection belongs
* @param ep
* the {@link org.apache.harmony.rmi.internal.transport.Endpoint} for this
* connection
* @throws ConnectIOException
* if an IOException occurs while making a connection to the
* remote host
*/
public AbstractClientConnection(Socket sock, Endpoint ep)
throws ConnectIOException {
this.ep = ep;
this.lastUsageTime = null;
clientConnectionID = ++clientConnectionCounter;
this.sock = sock;
try {
this.out = new DataOutputStream(new BufferedOutputStream(sock
.getOutputStream()));
this.in = new DataInputStream(new BufferedInputStream(sock
.getInputStream()));
} catch (IOException e) {
throw new ConnectIOException("I/O exception Creating Connection", e);
}
protocolHandler = new ClientProtocolHandler(this.in, this.out);
}
示例7: getClientConnection
import java.rmi.ConnectIOException; //导入依赖的package包/类
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;
}
示例8: AbstractClientConnection
import java.rmi.ConnectIOException; //导入依赖的package包/类
/**
* Creates a new connection to the specified
* {@link ar.org.fitc.rmi.transport.Endpoint} using the underlying
* {@link java.net.Socket}
*
* @param sock
* the {@link java.net.Socket} to which the connection belongs
* @param ep
* the {@link ar.org.fitc.rmi.transport.Endpoint} for this
* connection
* @throws ConnectIOException
* if an IOException occurs while making a connection to the
* remote host
*/
public AbstractClientConnection(Socket sock, Endpoint ep)
throws ConnectIOException {
this.ep = ep;
this.lastUsageTime = null;
clientConnectionID = ++clientConnectionCounter;
this.sock = sock;
try {
this.out = new DataOutputStream(new BufferedOutputStream(sock
.getOutputStream()));
this.in = new DataInputStream(new BufferedInputStream(sock
.getInputStream()));
} catch (IOException e) {
throw new ConnectIOException("I/O exception Creating Connection", e);
}
protocolHandler = new ClientProtocolHandler(this.in, this.out);
}
示例9: writeTransportHeader
import java.rmi.ConnectIOException; //导入依赖的package包/类
/**
* Send transport header over stream.
*/
private void writeTransportHeader(DataOutputStream out)
throws RemoteException
{
try {
// write out transport header
DataOutputStream dataOut =
new DataOutputStream(out);
dataOut.writeInt(TransportConstants.Magic);
dataOut.writeShort(TransportConstants.Version);
} catch (IOException e) {
throw new ConnectIOException(
"error writing JRMP transport header", e);
}
}
示例10: isLocalProblem
import java.rmi.ConnectIOException; //导入依赖的package包/类
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;
}
示例11: getRemoteFactoryHandle
import java.rmi.ConnectIOException; //导入依赖的package包/类
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;
}
示例12: serverProtocolAck
import java.rmi.ConnectIOException; //导入依赖的package包/类
/**
* Acknowledge protocol with server side.
*
* @return acknowledged protocol number
*
* @throws RemoteException if any I/O exception occurred during protocol
* acknowledgement
*/
protected int serverProtocolAck() throws RemoteException {
try {
DataOutputStream dout = new DataOutputStream(out);
// write RMI header and protocol version
writeHeader(dout);
// write protocol type
dout.writeByte(SINGLEOP_PROTOCOL);
dout.flush();
if (proxyTransportLog.isLoggable(RMILog.VERBOSE)) {
// rmi.log.130=Using singleop RMI protocol
proxyTransportLog.log(RMILog.VERBOSE,Messages.getString("rmi.log.130")); //$NON-NLS-1$
}
dout.flush();
} catch (RemoteException re) {
close();
throw re;
} catch (IOException ioe) {
close();
// rmi.8E=Unable to acknowledge protocol with server
throw new ConnectIOException(Messages.getString("rmi.8E"), ioe); //$NON-NLS-1$
}
// protocol is agreed
return SINGLEOP_PROTOCOL;
}
示例13: testConnectIOExceptionStringException
import java.rmi.ConnectIOException; //导入依赖的package包/类
/**
* {@link java.rmi.ConnectIOException#ConnectIOException(java.lang.String, java.lang.Exception)}.
*/
public void testConnectIOExceptionStringException() {
NullPointerException npe = new NullPointerException();
ConnectIOException e = new ConnectIOException("fixture", npe);
assertTrue(e.getMessage().indexOf("fixture") > -1);
assertSame(npe, e.getCause());
assertSame(npe, e.detail);
}
示例14: testConnectIOExceptionString
import java.rmi.ConnectIOException; //导入依赖的package包/类
/**
* {@link java.rmi.ConnectIOException#ConnectIOException(java.lang.String)}.
*/
public void testConnectIOExceptionString() {
ConnectIOException e = new ConnectIOException("fixture");
assertEquals("fixture", e.getMessage());
assertNull(e.getCause());
assertNull(e.detail);
}
示例15: main
import java.rmi.ConnectIOException; //导入依赖的package包/类
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);
}
}
}
}