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));
}
}
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);
}
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);
}
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));
}
}
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);
}
Aggregations