List of usage examples for java.util.concurrent.locks Lock lock
lock
From source file:info.pancancer.arch3.worker.WorkflowRunner.java
/** * Get the stderr of the running command. * * @return//from ww w. j a v a 2s . co m */ public String getStdErr() { String s; Lock lock = new ReentrantLock(); lock.lock(); try { this.errorStream.flush(); s = this.errorStream.getAllLinesAsString(); } finally { lock.unlock(); } return s; }
From source file:com.cloudera.oryx.ml.speed.als.ALSSpeedModel.java
public float[] getItemVector(String item) { Lock lock = yLock.readLock(); lock.lock(); try {//from w w w. j a v a2 s .com return Y.get(item); } finally { lock.unlock(); } }
From source file:com.cloudera.oryx.ml.speed.als.ALSSpeedModel.java
public Solver getXTXSolver() { RealMatrix XTX;//from w w w . j ava2s . co m Lock lock = xLock.readLock(); lock.lock(); try { XTX = VectorMath.transposeTimesSelf(X.values()); } finally { lock.unlock(); } return new LinearSystemSolver().getSolver(XTX); }
From source file:com.cloudera.oryx.ml.speed.als.ALSSpeedModel.java
public Solver getYTYSolver() { RealMatrix YTY;/*from w w w . ja va2 s.c o m*/ Lock lock = yLock.readLock(); lock.lock(); try { YTY = VectorMath.transposeTimesSelf(Y.values()); } finally { lock.unlock(); } return new LinearSystemSolver().getSolver(YTY); }
From source file:de.hoegertn.demo.cxfsimple.SpringStarter.java
public final void doStop() throws Exception { try {/* www . ja v a2s . c om*/ this.doBeforeSpringStop(); } catch (Exception e) { throw new RuntimeException("Before spring stop failed", e); } Lock writeLock = this.rwLock.writeLock(); try { writeLock.lock(); if (this.context.get() == null) { throw new RuntimeException("Not yet started"); } this.context.get().stop(); this.context.get().close(); this.context.set(null); } catch (Exception e) { throw new RuntimeException("spring stop failed", e); } finally { writeLock.unlock(); } try { this.doAfterSpringStop(); } catch (Exception e) { throw new RuntimeException("After spring stop failed", e); } }
From source file:com.cloudera.oryx.ml.speed.als.ALSSpeedModel.java
public void pruneX(Collection<String> users) { // Keep all users in the new model, or, that have been added since last model Lock lock = xLock.writeLock(); lock.lock(); try {//from w w w . ja va2 s . c o m X.removeIf(new KeyOnlyBiPredicate<>(new AndPredicate<>(new NotContainsPredicate<>(users), new NotContainsPredicate<>(recentNewUsers)))); recentNewUsers.clear(); } finally { lock.unlock(); } }
From source file:com.cloudera.oryx.ml.speed.als.ALSSpeedModel.java
public void pruneY(Collection<String> items) { // Keep all items in the new model, or, that have been added since last model Lock lock = yLock.writeLock(); lock.lock(); try {//from w w w .j av a 2s. c o m Y.removeIf(new KeyOnlyBiPredicate<>(new AndPredicate<>(new NotContainsPredicate<>(items), new NotContainsPredicate<>(recentNewItems)))); recentNewItems.clear(); } finally { lock.unlock(); } }
From source file:com.cloudera.oryx.ml.speed.als.ALSSpeedModel.java
public void setUserVector(String user, float[] vector) { Preconditions.checkNotNull(vector);//w ww . j a v a 2s .c o m Preconditions.checkArgument(vector.length == features); Lock lock = xLock.writeLock(); lock.lock(); try { if (X.put(user, vector) == null) { // User was actually new recentNewUsers.add(user); } } finally { lock.unlock(); } }
From source file:com.cloudera.oryx.ml.speed.als.ALSSpeedModel.java
public void setItemVector(String item, float[] vector) { Preconditions.checkNotNull(vector);//from ww w . j a v a 2s .com Preconditions.checkArgument(vector.length == features); Lock lock = yLock.writeLock(); lock.lock(); try { if (Y.put(item, vector) == null) { // Item was actually new recentNewItems.add(item); } } finally { lock.unlock(); } }
From source file:be.fgov.kszbcss.rhq.websphere.connector.security.TrustStoreManager.java
private KeyStore loadTrustStore() throws GeneralSecurityException, IOException { Lock lock = truststoreLock.readLock(); lock.lock(); try {/*w w w. j a v a 2s . c o m*/ KeyStore truststore = KeyStore.getInstance("JKS"); if (truststoreFile.exists()) { if (log.isDebugEnabled()) { log.debug("Loading existing trust store from " + truststoreFile); } InputStream in = new FileInputStream(truststoreFile); try { truststore.load(in, new char[0]); } finally { in.close(); } if (log.isDebugEnabled()) { log.debug("Trust store has " + truststore.size() + " existing entries"); } } else { if (log.isDebugEnabled()) { log.debug("Trust store " + truststoreFile + " doesn't exist yet; a new one will be created if necessary"); } truststore.load(null); } return truststore; } finally { lock.unlock(); } }