List of usage examples for java.util.concurrent.locks ReentrantLock ReentrantLock
public ReentrantLock()
From source file:com.vmware.identity.session.Session.java
/** * Construct the object//from w w w . ja v a2s . c om * * @param principalId * @param expireDate * @param authnMethod * @throws NoSuchAlgorithmException */ public Session(PrincipalId principalId, Date expireDate, AuthnMethod authnMethod) throws NoSuchAlgorithmException { Validate.notNull(principalId); Validate.notNull(expireDate); SecureRandomIdentifierGenerator generator = new SecureRandomIdentifierGenerator(); this.id = generator.generateIdentifier(); this.principalId = principalId; this.expireDate = expireDate; this.authnMethod = authnMethod; this.participants = new HashMap<String, SessionParticipant>(); this.participantsByUrl = new HashMap<String, SessionParticipant>(); this.lock = new ReentrantLock(); this.usingExtIDP = false; this.extIDPUsed = null; this.extIDPSessionID = null; }
From source file:org.ops4j.pax.runner.platform.internal.Activator.java
/** * Creates a new activator. */ public Activator() { m_lock = new ReentrantLock(); }
From source file:com.greplin.zookeeper.RobustZooKeeper.java
public RobustZooKeeper(String ensembleAddresses) throws IOException { this.reconnectCount = new AtomicInteger(-1); // start at -1 so that the initial connection doesn't count this.shutdown = new AtomicBoolean(false); this.reconnectLock = new ReentrantLock(); this.ensembleAddress = ensembleAddresses; this.client = null; clientNumber = INSTANCE_COUNTER.incrementAndGet(); }
From source file:ai.grakn.engine.tasks.manager.StandaloneTaskManager.java
public StandaloneTaskManager(EngineID engineId) { this.engineID = engineId; instantiatedTasks = new ConcurrentHashMap<>(); stateStorage = new TaskStateInMemoryStore(); stateUpdateLock = new ReentrantLock(); ConfigProperties properties = ConfigProperties.getInstance(); schedulingService = Executors.newScheduledThreadPool(1); executorService = Executors.newFixedThreadPool(properties.getAvailableThreads()); }
From source file:org.apache.zookeeper.MockZooKeeper.java
public static MockZooKeeper newInstance(ExecutorService executor, int readOpDelayMs) { try {//from ww w. j ava2s.c om sun.reflect.ReflectionFactory rf = sun.reflect.ReflectionFactory.getReflectionFactory(); Constructor objDef = Object.class.getDeclaredConstructor(new Class[0]); Constructor intConstr = rf.newConstructorForSerialization(MockZooKeeper.class, objDef); MockZooKeeper zk = MockZooKeeper.class.cast(intConstr.newInstance()); zk.init(executor); zk.readOpDelayMs = readOpDelayMs; zk.mutex = new ReentrantLock(); return zk; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new IllegalStateException("Cannot create object", e); } }
From source file:ai.grakn.engine.backgroundtasks.standalone.StandaloneTaskManager.java
private StandaloneTaskManager() { instantiatedTasks = new ConcurrentHashMap<>(); stateStorage = InMemoryStateStorage.getInstance(); stateUpdateLock = new ReentrantLock(); ConfigProperties properties = ConfigProperties.getInstance(); schedulingService = Executors.newScheduledThreadPool(1); executorService = Executors.newFixedThreadPool(properties.getAvailableThreads()); }
From source file:org.ut.biolab.medsavant.server.db.LockController.java
/** * Obtain a lock. If another thread already owns the lock, an exception will * be thrown./*from ww w .ja v a 2 s . co m*/ * * @param database The database with the project to be unlocked. * @param projectID The project ID to lock * @throws LockException */ public synchronized void requestLock(String database, int projectID) throws LockException { LOG.info("Server lock requested"); Key key = new Key(database, projectID); ReentrantLock lock = locks.get(key); // create the lock if one doesn't exist for the project if (lock == null) { lock = new ReentrantLock(); locks.put(key, lock); } // lock it down // (if this thread owns the lock, call lock again which will increase the hold count) if (!lock.isLocked() || lock.isHeldByCurrentThread()) { lock.lock(); LOG.info(String.format("Server locked - hold count %d", lock.getHoldCount())); } else { throw new LockException("Database is locked for changes"); } }
From source file:org.wso2.carbon.sequences.SequenceAdminUtil.java
public static Lock getLock() throws SequenceEditorException { Parameter p = ConfigHolder.getInstance().getAxisConfiguration() .getParameter(ServiceBusConstants.SYNAPSE_CONFIG_LOCK); if (p != null) { return (Lock) p.getValue(); } else {/*from w w w . ja va 2 s. c o m*/ log.warn(ServiceBusConstants.SYNAPSE_CONFIG_LOCK + " is null, Recreating a new lock"); Lock lock = new ReentrantLock(); try { ConfigHolder.getInstance().getAxisConfiguration() .addParameter(ServiceBusConstants.SYNAPSE_CONFIG_LOCK, lock); return lock; } catch (AxisFault axisFault) { log.error("Error while setting " + ServiceBusConstants.SYNAPSE_CONFIG_LOCK); } } return null; }
From source file:com.swissbit.homeautomation.asyncTask.AuthenticationAsync.java
/** *Constructor/*from w w w.j a va 2 s . c o m*/ */ public AuthenticationAsync(Context context, final String rid) { this.mainActivity = (MainActivity) context; this.mainActivityContext = context; this.rid = rid; subscriptionResponse = false; lock = new ReentrantLock(); condition = lock.newCondition(); }
From source file:org.apache.marmotta.platform.core.startup.MarmottaStartupService.java
@PostConstruct public void initialise() { lock = new ReentrantLock(); }