org.apache.catalina.tribes.io.ReplicationStream Java Examples

The following examples show how to use org.apache.catalina.tribes.io.ReplicationStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeltaSession.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Applies a diff to an existing object.
 * @param diff byte[]
 * @param offset int
 * @param length int
 * @throws IOException
 */
@Override
public void applyDiff(byte[] diff, int offset, int length) throws IOException, ClassNotFoundException {
    try {
        lock();
        ReplicationStream stream = ( (ClusterManager) getManager()).getReplicationStream(diff, offset, length);
        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
        try {
            ClassLoader[] loaders = getClassLoaders();
            if (loaders != null && loaders.length > 0)
                Thread.currentThread().setContextClassLoader(loaders[0]);
            getDeltaRequest().readExternal(stream);
            getDeltaRequest().execute(this, ((ClusterManager)getManager()).isNotifyListenersOnReplication());
            stream.close();
        } finally {
            Thread.currentThread().setContextClassLoader(contextLoader);
        }
    }finally {
        unlock();
    }
}
 
Example #2
Source File: DeltaSession.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Applies a diff to an existing object.
 * @param diff byte[]
 * @param offset int
 * @param length int
 * @throws IOException
 */
@Override
public void applyDiff(byte[] diff, int offset, int length) throws IOException, ClassNotFoundException {
    try {
        lock();
        ReplicationStream stream = ( (ClusterManager) getManager()).getReplicationStream(diff, offset, length);
        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
        try {
            ClassLoader[] loaders = getClassLoaders();
            if (loaders != null && loaders.length > 0)
                Thread.currentThread().setContextClassLoader(loaders[0]);
            getDeltaRequest().readExternal(stream);
            getDeltaRequest().execute(this, ((ClusterManager)getManager()).isNotifyListenersOnReplication());
            stream.close();
        } finally {
            Thread.currentThread().setContextClassLoader(contextLoader);
        }
    }finally {
        unlock();
    }
}
 
Example #3
Source File: DeltaManager.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Load sessionID
 * @param data serialized session id
 * @return session id
 * @throws IOException if an input/output error occurs
 */
protected String deserializeSessionId(byte[] data) throws IOException {
    ReplicationStream ois = getReplicationStream(data);
    String sessionId = ois.readUTF();
    ois.close();
    return sessionId;
}
 
Example #4
Source File: DeltaManager.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Load sessionID
 * @throws IOException if an input/output error occurs
 */
protected String deserializeSessionId(byte[] data) throws IOException {
    ReplicationStream ois = getReplicationStream(data);
    String sessionId = ois.readUTF();
    ois.close();
    return sessionId;
}
 
Example #5
Source File: DeltaManager.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Load Deltarequest from external node
 * Load the Class at container classloader
 * @see DeltaRequest#readExternal(java.io.ObjectInput)
 * @param session
 * @param data message data
 * @return The request
 * @throws ClassNotFoundException
 * @throws IOException
 */
protected DeltaRequest deserializeDeltaRequest(DeltaSession session, byte[] data) throws ClassNotFoundException, IOException {
    try {
        session.lock();
        ReplicationStream ois = getReplicationStream(data);
        session.getDeltaRequest().readExternal(ois);
        ois.close();
        return session.getDeltaRequest();
    }finally {
        session.unlock();
    }
}
 
Example #6
Source File: DeltaSession.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected void deserializeAndExecuteDeltaRequest(byte[] delta) throws IOException, ClassNotFoundException {
    if (manager instanceof ClusterManagerBase) {
        SynchronizedStack<DeltaRequest> deltaRequestPool =
                ((ClusterManagerBase) manager).getDeltaRequestPool();

        DeltaRequest newDeltaRequest = deltaRequestPool.pop();
        if (newDeltaRequest == null) {
            newDeltaRequest = new DeltaRequest(null, ((ClusterManagerBase) manager).isRecordAllActions());
        }

        ReplicationStream ois = ((ClusterManagerBase) manager).getReplicationStream(delta);
        newDeltaRequest.readExternal(ois);
        ois.close();

        DeltaRequest oldDeltaRequest = null;
        lockInternal();
        try {
            oldDeltaRequest = replaceDeltaRequest(newDeltaRequest);
            newDeltaRequest.execute(this, ((ClusterManagerBase) manager).isNotifyListenersOnReplication());
            setPrimarySession(false);
        } finally {
            unlockInternal();
            if (oldDeltaRequest != null) {
                oldDeltaRequest.reset();
                deltaRequestPool.push(oldDeltaRequest);
            }
        }
    }
}
 
Example #7
Source File: DeltaManager.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Load Deltarequest from external node
 * Load the Class at container classloader
 * @see DeltaRequest#readExternal(java.io.ObjectInput)
 * @param session
 * @param data message data
 * @return The request
 * @throws ClassNotFoundException
 * @throws IOException
 */
protected DeltaRequest deserializeDeltaRequest(DeltaSession session, byte[] data) throws ClassNotFoundException, IOException {
    try {
        session.lock();
        ReplicationStream ois = getReplicationStream(data);
        session.getDeltaRequest().readExternal(ois);
        ois.close();
        return session.getDeltaRequest();
    }finally {
        session.unlock();
    }
}
 
Example #8
Source File: DeltaManager.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Load sessionID
 * @throws IOException if an input/output error occurs
 */
protected String deserializeSessionId(byte[] data) throws IOException {
    ReplicationStream ois = getReplicationStream(data);
    String sessionId = ois.readUTF();
    ois.close();
    return sessionId;
}
 
Example #9
Source File: ClusterManagerBase.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public ReplicationStream getReplicationStream(byte[] data) throws IOException {
    return getReplicationStream(data,0,data.length);
}
 
Example #10
Source File: ClusterManagerBase.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public ReplicationStream getReplicationStream(byte[] data, int offset, int length) throws IOException {
    ByteArrayInputStream fis = new ByteArrayInputStream(data, offset, length);
    return new ReplicationStream(fis, getClassLoaders());
}
 
Example #11
Source File: ClusterManagerBase.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public ReplicationStream getReplicationStream(byte[] data, int offset, int length) throws IOException {
    ByteArrayInputStream fis = new ByteArrayInputStream(data, offset, length);
    return new ReplicationStream(fis, getClassLoaders());
}
 
Example #12
Source File: ClusterManagerBase.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public ReplicationStream getReplicationStream(byte[] data, int offset, int length) throws IOException {
    ByteArrayInputStream fis = new ByteArrayInputStream(data, offset, length);
    return new ReplicationStream(fis, getClassLoaders());
}
 
Example #13
Source File: ClusterManagerBase.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public ReplicationStream getReplicationStream(byte[] data) throws IOException {
    return getReplicationStream(data,0,data.length);
}
 
Example #14
Source File: DeltaManager.java    From Tomcat8-Source-Read with MIT License 3 votes vote down vote up
/**
 * Load Deltarequest from external node
 * Load the Class at container classloader
 * @see DeltaRequest#readExternal(java.io.ObjectInput)
 * @param session Corresponding session
 * @param data message data
 * @return The request
 * @throws ClassNotFoundException Serialization error
 * @throws IOException IO error with serialization
 *
 * @deprecated Unused. This will be removed in Tomcat 10.
 *             Calling this method may result in a deadlock. See:
 *             https://bz.apache.org/bugzilla/show_bug.cgi?id=62841
 */
@Deprecated
protected DeltaRequest deserializeDeltaRequest(DeltaSession session, byte[] data)
        throws ClassNotFoundException, IOException {
    session.lock();
    try {
        ReplicationStream ois = getReplicationStream(data);
        session.getDeltaRequest().readExternal(ois);
        ois.close();
        return session.getDeltaRequest();
    } finally {
        session.unlock();
    }
}
 
Example #15
Source File: ClusterManagerBase.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * Open Stream and use correct ClassLoader (Container) Switch
 * ThreadClassLoader
 * 
 * @param data
 * @return The object input stream
 * @throws IOException
 */
@Override
public ReplicationStream getReplicationStream(byte[] data) throws IOException {
    return getReplicationStream(data,0,data.length);
}
 
Example #16
Source File: ClusterManager.java    From tomcatsrc with Apache License 2.0 2 votes vote down vote up
/**
 * Open stream and use correct ClassLoader (Container), switching thread
 * context class loader.
 *
 * @param data The data
 * @return The object input stream
 * @throws IOException An error occurred
 */
public ReplicationStream getReplicationStream(byte[] data) throws IOException;
 
Example #17
Source File: ClusterManager.java    From Tomcat8-Source-Read with MIT License 2 votes vote down vote up
/**
 * Open stream and use correct ClassLoader (Container), switching thread
 * context class loader.
 *
 * @param data The data
 * @return The object input stream
 * @throws IOException An error occurred
 */
public ReplicationStream getReplicationStream(byte[] data) throws IOException;
 
Example #18
Source File: ClusterManager.java    From Tomcat7.0.67 with Apache License 2.0 votes vote down vote up
public ReplicationStream getReplicationStream(byte[] data, int offset, int length) throws IOException; 
Example #19
Source File: ClusterManager.java    From Tomcat7.0.67 with Apache License 2.0 votes vote down vote up
public ReplicationStream getReplicationStream(byte[] data) throws IOException; 
Example #20
Source File: ClusterManager.java    From Tomcat8-Source-Read with MIT License votes vote down vote up
public ReplicationStream getReplicationStream(byte[] data, int offset, int length) throws IOException; 
Example #21
Source File: ClusterManager.java    From tomcatsrc with Apache License 2.0 votes vote down vote up
public ReplicationStream getReplicationStream(byte[] data, int offset, int length) throws IOException;