Search in sources :

Example 1 with DefaultOperationLockManager

use of com.b2international.snowowl.core.locks.DefaultOperationLockManager 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)

Aggregations

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 RpcSession (com.b2international.snowowl.rpc.RpcSession)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1