Search in sources :

Example 1 with ActivationGroupID

use of java.rmi.activation.ActivationGroupID in project jdk8u_jdk by JetBrains.

the class PipeWriter method init.

/**
     * Initialize the Activation instantiation; start activation
     * services.
     */
private void init(int port, RMIServerSocketFactory ssf, ReliableLog log, String[] childArgs) throws Exception {
    // initialize
    this.log = log;
    numUpdates = 0;
    shutdownHook = new ShutdownHook();
    groupSemaphore = getInt("sun.rmi.activation.groupThrottle", 3);
    groupCounter = 0;
    Runtime.getRuntime().addShutdownHook(shutdownHook);
    // Use array size of 0, since the value from calling size()
    // may be out of date by the time toArray() is called.
    ActivationGroupID[] gids = groupTable.keySet().toArray(new ActivationGroupID[0]);
    synchronized (startupLock = new Object()) {
        // all the remote methods briefly synchronize on startupLock
        // (via checkShutdown) to make sure they don't happen in the
        // middle of this block.  This block must not cause any such
        // incoming remote calls to happen, or deadlock would result!
        activator = new ActivatorImpl(port, ssf);
        activatorStub = (Activator) RemoteObject.toStub(activator);
        system = new ActivationSystemImpl(port, ssf);
        systemStub = (ActivationSystem) RemoteObject.toStub(system);
        monitor = new ActivationMonitorImpl(port, ssf);
        initCommand(childArgs);
        registry = new SystemRegistryImpl(port, null, ssf, systemStub);
        if (ssf != null) {
            synchronized (initLock) {
                initDone = true;
                initLock.notifyAll();
            }
        }
    }
    startupLock = null;
    // restart services
    for (int i = gids.length; --i >= 0; ) {
        try {
            getGroupEntry(gids[i]).restartServices();
        } catch (UnknownGroupException e) {
            System.err.println(getTextResource("rmid.restart.group.warning"));
            e.printStackTrace();
        }
    }
}
Also used : ActivationGroupID(java.rmi.activation.ActivationGroupID) UnknownGroupException(java.rmi.activation.UnknownGroupException) MarshalledObject(java.rmi.MarshalledObject) UnicastRemoteObject(java.rmi.server.UnicastRemoteObject) RemoteObject(java.rmi.server.RemoteObject)

Example 2 with ActivationGroupID

use of java.rmi.activation.ActivationGroupID in project jdk8u_jdk by JetBrains.

the class ActivationGroupInit method main.

/**
     * Main program to start a VM for an activation group.
     */
public static void main(String[] args) {
    try {
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new SecurityManager());
        }
        // read group id, descriptor, and incarnation number from stdin
        MarshalInputStream in = new MarshalInputStream(System.in);
        ActivationGroupID id = (ActivationGroupID) in.readObject();
        ActivationGroupDesc desc = (ActivationGroupDesc) in.readObject();
        long incarnation = in.readLong();
        // create and set group for the VM
        ActivationGroup.createGroup(id, desc, incarnation);
    } catch (Exception e) {
        System.err.println("Exception in starting ActivationGroupInit:");
        e.printStackTrace();
    } finally {
        try {
            System.in.close();
        // note: system out/err shouldn't be closed
        // since the parent may want to read them.
        } catch (Exception ex) {
        // ignore exceptions
        }
    }
}
Also used : ActivationGroupID(java.rmi.activation.ActivationGroupID) ActivationGroupDesc(java.rmi.activation.ActivationGroupDesc)

Example 3 with ActivationGroupID

use of java.rmi.activation.ActivationGroupID in project jdk8u_jdk by JetBrains.

the class PipeWriter method getGroupEntry.

/**
     * Returns the group entry for the object's id. Throws
     * UnknownObjectException if the object is not registered or the
     * object's group is not registered.
     */
private GroupEntry getGroupEntry(ActivationID id) throws UnknownObjectException {
    ActivationGroupID gid = getGroupID(id);
    GroupEntry entry = groupTable.get(gid);
    if (entry != null && !entry.removed) {
        return entry;
    }
    throw new UnknownObjectException("object's group removed");
}
Also used : ActivationGroupID(java.rmi.activation.ActivationGroupID) UnknownObjectException(java.rmi.activation.UnknownObjectException)

Example 4 with ActivationGroupID

use of java.rmi.activation.ActivationGroupID in project jdk8u_jdk by JetBrains.

the class IdempotentActiveGroup method main.

public static void main(String[] args) {
    System.err.println("\nRegression test for bug 4720528\n");
    TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
    RMID rmid = null;
    ActivationInstantiator inst1 = null;
    ActivationInstantiator inst2 = null;
    try {
        RMID.removeLog();
        rmid = RMID.createRMID();
        rmid.start();
        System.err.println("Create group descriptor");
        ActivationGroupDesc groupDesc = new ActivationGroupDesc(null, null);
        ActivationSystem system = ActivationGroup.getSystem();
        System.err.println("Register group descriptor");
        ActivationGroupID groupID = system.registerGroup(groupDesc);
        inst1 = new FakeInstantiator();
        inst2 = new FakeInstantiator();
        System.err.println("Invoke activeGroup with inst1");
        system.activeGroup(groupID, inst1, 0);
        try {
            System.err.println("Invoke activeGroup with inst2");
            system.activeGroup(groupID, inst2, 0);
            throw new RuntimeException("TEST FAILED: activeGroup with unequal groups succeeded!");
        } catch (ActivationException expected) {
            System.err.println("Caught expected ActivationException");
            System.err.println("Test 1 (of 2) passed");
        }
        try {
            System.err.println("Invoke activeGroup with inst1");
            system.activeGroup(groupID, inst1, 0);
            System.err.println("activeGroup call succeeded");
            System.err.println("Test 2 (of 2) passed");
        } catch (ActivationException unexpected) {
            throw new RuntimeException("TEST FAILED: activeGroup with equal groups failed!", unexpected);
        }
    } catch (Exception e) {
        TestLibrary.bomb("test failed", e);
    } finally {
        try {
            if (inst1 != null) {
                UnicastRemoteObject.unexportObject(inst1, true);
            }
            if (inst2 != null) {
                UnicastRemoteObject.unexportObject(inst2, true);
            }
        } catch (NoSuchObjectException unexpected) {
            throw new AssertionError(unexpected);
        }
        ActivationLibrary.rmidCleanup(rmid);
    }
}
Also used : ActivationSystem(java.rmi.activation.ActivationSystem) ActivationGroupID(java.rmi.activation.ActivationGroupID) ActivationInstantiator(java.rmi.activation.ActivationInstantiator) ActivationException(java.rmi.activation.ActivationException) ActivationGroupDesc(java.rmi.activation.ActivationGroupDesc) NoSuchObjectException(java.rmi.NoSuchObjectException) NoSuchObjectException(java.rmi.NoSuchObjectException) ActivationException(java.rmi.activation.ActivationException) RemoteException(java.rmi.RemoteException)

Aggregations

ActivationGroupID (java.rmi.activation.ActivationGroupID)4 ActivationGroupDesc (java.rmi.activation.ActivationGroupDesc)2 MarshalledObject (java.rmi.MarshalledObject)1 NoSuchObjectException (java.rmi.NoSuchObjectException)1 RemoteException (java.rmi.RemoteException)1 ActivationException (java.rmi.activation.ActivationException)1 ActivationInstantiator (java.rmi.activation.ActivationInstantiator)1 ActivationSystem (java.rmi.activation.ActivationSystem)1 UnknownGroupException (java.rmi.activation.UnknownGroupException)1 UnknownObjectException (java.rmi.activation.UnknownObjectException)1 RemoteObject (java.rmi.server.RemoteObject)1 UnicastRemoteObject (java.rmi.server.UnicastRemoteObject)1