use of java.rmi.server.ServerNotActiveException in project jdk8u_jdk by JetBrains.
the class RMIServerImpl method makeConnectionId.
private static synchronized String makeConnectionId(String protocol, Subject subject) {
connectionIdNumber++;
String clientHost = "";
try {
clientHost = RemoteServer.getClientHost();
/*
* According to the rules specified in the javax.management.remote
* package description, a numeric IPv6 address (detected by the
* presence of otherwise forbidden ":" character) forming a part
* of the connection id must be enclosed in square brackets.
*/
if (clientHost.contains(":")) {
clientHost = "[" + clientHost + "]";
}
} catch (ServerNotActiveException e) {
logger.trace("makeConnectionId", "getClientHost", e);
}
final StringBuilder buf = new StringBuilder();
buf.append(protocol).append(":");
if (clientHost.length() > 0)
buf.append("//").append(clientHost);
buf.append(" ");
if (subject != null) {
Set<Principal> principals = subject.getPrincipals();
String sep = "";
for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
Principal p = it.next();
String name = p.getName().replace(' ', '_').replace(';', ':');
buf.append(sep).append(name);
sep = ";";
}
}
buf.append(" ").append(connectionIdNumber);
if (logger.traceOn())
logger.trace("newConnectionId", "connectionId=" + buf);
return buf.toString();
}
use of java.rmi.server.ServerNotActiveException in project jdk8u_jdk by JetBrains.
the class Transport method serviceCall.
/**
* Service an incoming remote call. When a message arrives on the
* connection indicating the beginning of a remote call, the
* threads are required to call the <I>serviceCall</I> method of
* their transport. The default implementation of this method
* locates and calls the dispatcher object. Ordinarily a
* transport implementation will not need to override this method.
* At the entry to <I>tr.serviceCall(conn)</I>, the connection's
* input stream is positioned at the start of the incoming
* message. The <I>serviceCall</I> method processes the incoming
* remote invocation and sends the result on the connection's
* output stream. If it returns "true", then the remote
* invocation was processed without error and the transport can
* cache the connection. If it returns "false", a protocol error
* occurred during the call, and the transport should destroy the
* connection.
*/
public boolean serviceCall(final RemoteCall call) {
try {
/* read object id */
final Remote impl;
ObjID id;
try {
id = ObjID.read(call.getInputStream());
} catch (java.io.IOException e) {
throw new MarshalException("unable to read objID", e);
}
/* get the remote object */
Transport transport = id.equals(dgcID) ? null : this;
Target target = ObjectTable.getTarget(new ObjectEndpoint(id, transport));
if (target == null || (impl = target.getImpl()) == null) {
throw new NoSuchObjectException("no such object in table");
}
final Dispatcher disp = target.getDispatcher();
target.incrementCallCount();
try {
/* call the dispatcher */
transportLog.log(Log.VERBOSE, "call dispatcher");
final AccessControlContext acc = target.getAccessControlContext();
ClassLoader ccl = target.getContextClassLoader();
ClassLoader savedCcl = Thread.currentThread().getContextClassLoader();
try {
setContextClassLoader(ccl);
currentTransport.set(this);
try {
java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<Void>() {
public Void run() throws IOException {
checkAcceptPermission(acc);
disp.dispatch(impl, call);
return null;
}
}, acc);
} catch (java.security.PrivilegedActionException pae) {
throw (IOException) pae.getException();
}
} finally {
setContextClassLoader(savedCcl);
currentTransport.set(null);
}
} catch (IOException ex) {
transportLog.log(Log.BRIEF, "exception thrown by dispatcher: ", ex);
return false;
} finally {
target.decrementCallCount();
}
} catch (RemoteException e) {
// if calls are being logged, write out exception
if (UnicastServerRef.callLog.isLoggable(Log.BRIEF)) {
// include client host name if possible
String clientHost = "";
try {
clientHost = "[" + RemoteServer.getClientHost() + "] ";
} catch (ServerNotActiveException ex) {
}
String message = clientHost + "exception: ";
UnicastServerRef.callLog.log(Log.BRIEF, message, e);
}
/* We will get a RemoteException if either a) the objID is
* not readable, b) the target is not in the object table, or
* c) the object is in the midst of being unexported (note:
* NoSuchObjectException is thrown by the incrementCallCount
* method if the object is being unexported). Here it is
* relatively safe to marshal an exception to the client
* since the client will not have seen a return value yet.
*/
try {
ObjectOutput out = call.getResultStream(false);
UnicastServerRef.clearStackTraces(e);
out.writeObject(e);
call.releaseOutputStream();
} catch (IOException ie) {
transportLog.log(Log.BRIEF, "exception thrown marshalling exception: ", ie);
return false;
}
}
return true;
}
use of java.rmi.server.ServerNotActiveException in project jdk8u_jdk by JetBrains.
the class DGCImpl method dirty.
/**
* The dirty call adds the VMID "vmid" to the set of clients
* that hold references to the object associated with the ObjID
* id. The long "sequenceNum" is used to detect late dirty calls. If
* the VMID "vmid" is null, a VMID will be generated on the
* server (for use by the client in subsequent calls) and
* returned.
*
* The client must call the "dirty" method to renew the lease
* before the "lease" time expires or all references to remote
* objects in this VM that the client holds are considered
* "unreferenced".
*/
public Lease dirty(ObjID[] ids, long sequenceNum, Lease lease) {
VMID vmid = lease.getVMID();
/*
* The server specifies the lease value; the client has
* no say in the matter.
*/
long duration = leaseValue;
if (dgcLog.isLoggable(Log.VERBOSE)) {
dgcLog.log(Log.VERBOSE, "vmid = " + vmid);
}
// create a VMID if one wasn't supplied
if (vmid == null) {
vmid = new VMID();
if (dgcLog.isLoggable(Log.BRIEF)) {
String clientHost;
try {
clientHost = RemoteServer.getClientHost();
} catch (ServerNotActiveException e) {
clientHost = "<unknown host>";
}
dgcLog.log(Log.BRIEF, " assigning vmid " + vmid + " to client " + clientHost);
}
}
lease = new Lease(vmid, duration);
// record lease information
synchronized (leaseTable) {
LeaseInfo info = leaseTable.get(vmid);
if (info == null) {
leaseTable.put(vmid, new LeaseInfo(vmid, duration));
if (checker == null) {
checker = scheduler.scheduleWithFixedDelay(new Runnable() {
public void run() {
checkLeases();
}
}, leaseCheckInterval, leaseCheckInterval, TimeUnit.MILLISECONDS);
}
} else {
info.renew(duration);
}
}
for (ObjID id : ids) {
if (dgcLog.isLoggable(Log.VERBOSE)) {
dgcLog.log(Log.VERBOSE, "id = " + id + ", vmid = " + vmid + ", duration = " + duration);
}
ObjectTable.referenced(id, sequenceNum, vmid);
}
// return the VMID used
return lease;
}
Aggregations