Search in sources :

Example 1 with RpcSession

use of com.b2international.snowowl.rpc.RpcSession in project snow-owl by b2ihealthcare.

the class LockPlugin method preRun.

@Override
public void preRun(SnowOwlConfiguration configuration, Environment env) throws Exception {
    if (env.isServer()) {
        final Index locksIndex = Indexes.createIndex(LOCKS_INDEX, env.service(ObjectMapper.class), new Mappings(DatastoreLockIndexEntry.class), env.service(IndexSettings.class).forIndex(env.service(RepositoryConfiguration.class).getIndexConfiguration(), LOCKS_INDEX));
        final DefaultOperationLockManager lockManager = new DefaultOperationLockManager(locksIndex);
        final RemoteLockTargetListener remoteLockTargetListener = new RemoteLockTargetListener();
        lockManager.addLockTargetListener(new Slf4jOperationLockTargetListener());
        lockManager.addLockTargetListener(remoteLockTargetListener);
        env.services().registerService(IOperationLockManager.class, lockManager);
        final RpcSession session = RpcUtil.getInitialServerSession(env.container());
        session.registerClassLoader(IOperationLockManager.class, DefaultOperationLockManager.class.getClassLoader());
    } else {
        env.services().registerService(IOperationLockManager.class, RpcUtil.createProxy(env.container(), IOperationLockManager.class));
    }
}
Also used : Mappings(com.b2international.index.mapping.Mappings) DatastoreLockIndexEntry(com.b2international.snowowl.core.locks.DatastoreLockIndexEntry) RpcSession(com.b2international.snowowl.rpc.RpcSession) Index(com.b2international.index.Index) IOperationLockManager(com.b2international.snowowl.core.locks.IOperationLockManager) RepositoryConfiguration(com.b2international.snowowl.core.config.RepositoryConfiguration) DefaultOperationLockManager(com.b2international.snowowl.core.locks.DefaultOperationLockManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with RpcSession

use of com.b2international.snowowl.rpc.RpcSession in project snow-owl by b2ihealthcare.

the class AbstractRpcTest method initializeService.

protected T initializeService() {
    final IConnector connector = JVMUtil.getConnector(container, JVM_DESCRIPTION);
    serviceImplementation = createServiceImplementation();
    final SingleServiceLookup<U> singleServiceLookup = new SingleServiceLookup<U>(serviceImplementation);
    final RpcSession initialServerSession = RpcUtil.getInitialServerSession(container);
    initialServerSession.registerClassLoader(serviceInterfaceClass, serviceImplementation.getClass().getClassLoader());
    initialServerSession.registerServiceLookup(singleServiceLookup);
    final RpcProtocol protocol = RpcUtil.getRpcClientProtocol(container);
    protocol.registerClassLoader(serviceInterfaceClass, serviceInterfaceClass.getClassLoader());
    protocol.open(connector);
    protocol.setTimeout(PROTOCOL_TIMEOUT_MILLIS);
    return protocol.getServiceProxy(serviceInterfaceClass);
}
Also used : RpcProtocol(com.b2international.snowowl.rpc.RpcProtocol) RpcSession(com.b2international.snowowl.rpc.RpcSession) SingleServiceLookup(com.b2international.snowowl.rpc.test.service.SingleServiceLookup) IConnector(org.eclipse.net4j.connector.IConnector)

Example 3 with RpcSession

use of com.b2international.snowowl.rpc.RpcSession in project snow-owl by b2ihealthcare.

the class RemoteLockTargetListener method targetReleased.

@Override
public void targetReleased(final DatastoreLockTarget target, final DatastoreLockContext context) {
    final RpcSession session = RpcThreadLocal.getSessionUnchecked();
    if (null == session) {
        return;
    }
    if (!remotelyLockedContexts.containsKey(session)) {
        return;
    }
    final Multimap<DatastoreLockTarget, DatastoreLockContext> targetsForSession = remotelyLockedContexts.get(session);
    targetsForSession.remove(target, context);
}
Also used : RpcSession(com.b2international.snowowl.rpc.RpcSession)

Example 4 with RpcSession

use of com.b2international.snowowl.rpc.RpcSession in project snow-owl by b2ihealthcare.

the class AttachmentPlugin method preRun.

@Override
public void preRun(SnowOwlConfiguration configuration, Environment env) throws Exception {
    if (env.isServer()) {
        env.services().registerService(AttachmentRegistry.class, new DefaultAttachmentRegistry(env.getDataPath().resolve(ATTACHMENTS_FOLDER)));
        final RpcSession session = RpcUtil.getInitialServerSession(env.container());
        session.registerClassLoader(AttachmentRegistry.class, DefaultAttachmentRegistry.class.getClassLoader());
    } else {
        // register service proxy in remote mode
        env.services().registerService(AttachmentRegistry.class, RpcUtil.createProxy(env.container(), AttachmentRegistry.class));
    }
}
Also used : RpcSession(com.b2international.snowowl.rpc.RpcSession)

Example 5 with RpcSession

use of com.b2international.snowowl.rpc.RpcSession in project snow-owl by b2ihealthcare.

the class RemoteLockTargetListener method targetAcquired.

@Override
public void targetAcquired(final DatastoreLockTarget target, final DatastoreLockContext context) {
    final RpcSession session = RpcThreadLocal.getSessionUnchecked();
    if (null == session) {
        return;
    }
    final Multimap<DatastoreLockTarget, DatastoreLockContext> targetsForSession;
    if (remotelyLockedContexts.containsKey(session)) {
        targetsForSession = remotelyLockedContexts.get(session);
    } else {
        targetsForSession = HashMultimap.create();
        remotelyLockedContexts.put(session, targetsForSession);
    }
    targetsForSession.put(target, context);
}
Also used : RpcSession(com.b2international.snowowl.rpc.RpcSession)

Aggregations

RpcSession (com.b2international.snowowl.rpc.RpcSession)5 Index (com.b2international.index.Index)1 Mappings (com.b2international.index.mapping.Mappings)1 RepositoryConfiguration (com.b2international.snowowl.core.config.RepositoryConfiguration)1 DatastoreLockIndexEntry (com.b2international.snowowl.core.locks.DatastoreLockIndexEntry)1 DefaultOperationLockManager (com.b2international.snowowl.core.locks.DefaultOperationLockManager)1 IOperationLockManager (com.b2international.snowowl.core.locks.IOperationLockManager)1 RpcProtocol (com.b2international.snowowl.rpc.RpcProtocol)1 SingleServiceLookup (com.b2international.snowowl.rpc.test.service.SingleServiceLookup)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IConnector (org.eclipse.net4j.connector.IConnector)1