本文整理汇总了Java中org.alfresco.repo.lock.LockAcquisitionException类的典型用法代码示例。如果您正苦于以下问题:Java LockAcquisitionException类的具体用法?Java LockAcquisitionException怎么用?Java LockAcquisitionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LockAcquisitionException类属于org.alfresco.repo.lock包,在下文中一共展示了LockAcquisitionException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: lock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private String lock(final QName lockName, final long timeToLive, boolean expectSuccess)
{
try
{
String token = lock(lockName, timeToLive);
if (!expectSuccess)
{
fail("Expected lock " + lockName + " to have been denied");
}
return token;
}
catch (LockAcquisitionException e)
{
if (expectSuccess)
{
// oops
throw new RuntimeException("Expected to get lock " + lockName + " with TTL of " + timeToLive, e);
}
else
{
return null;
}
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:LockDAOTest.java
示例2: refresh
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private void refresh(final QName lockName, final String lockToken, final long timeToLive, boolean expectSuccess)
{
RetryingTransactionCallback<Boolean> callback = new RetryingTransactionCallback<Boolean>()
{
public Boolean execute() throws Throwable
{
lockDAO.refreshLock(lockName, lockToken, timeToLive);
return Boolean.TRUE;
}
};
try
{
txnHelper.doInTransaction(callback);
if (!expectSuccess)
{
fail("Expected to have failed to refresh lock " + lockName);
}
}
catch (LockAcquisitionException e)
{
if (expectSuccess)
{
throw new RuntimeException("Expected to have refreshed lock " + lockName, e);
}
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:LockDAOTest.java
示例3: release
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private void release(final QName lockName, final String lockToken, boolean expectSuccess)
{
RetryingTransactionCallback<Boolean> callback = new RetryingTransactionCallback<Boolean>()
{
public Boolean execute() throws Throwable
{
lockDAO.releaseLock(lockName, lockToken, false);
return Boolean.TRUE;
}
};
try
{
txnHelper.doInTransaction(callback);
if (!expectSuccess)
{
fail("Expected to have failed to release lock " + lockName);
}
}
catch (LockAcquisitionException e)
{
if (expectSuccess)
{
throw new RuntimeException("Expected to have released lock " + lockName, e);
}
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:LockDAOTest.java
示例4: refreshExecutorLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private void refreshExecutorLock(String lockToken)
{
if (lockToken != null)
{
try
{
alfrescoJobExecutor.getJobLockService().refreshLock(lockToken, LOCK_QNAME, jobLockTTL);
if (logger.isTraceEnabled())
{
logger.trace(Thread.currentThread().getName() + " refreshed lock token: " + lockToken);
}
}
catch (LockAcquisitionException e)
{
if (logger.isTraceEnabled())
{
logger.trace("Failed to refresh Alfresco Job Executor lock - may no longer exist (" + lockToken
+ ")");
}
throw e;
}
}
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:AlfrescoJobExecutorThread.java
示例5: releaseExecutorLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private void releaseExecutorLock(String lockToken)
{
if (lockToken != null)
{
try
{
alfrescoJobExecutor.getJobLockService().releaseLock(lockToken, LOCK_QNAME);
if (logger.isTraceEnabled())
{
logger.trace(Thread.currentThread().getName() + " released lock token: " + lockToken);
}
}
catch (LockAcquisitionException e)
{
if (logger.isTraceEnabled())
{
logger.trace("Failed to release Alfresco Job Executor lock - may no longer exist (" + lockToken
+ ")");
}
throw e;
}
}
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:AlfrescoJobExecutorThread.java
示例6: getLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
/**
* Attempts to get the lock. If the lock couldn't be taken, then <tt>null</tt> is returned.
*
* @return Returns the lock token or <tt>null</tt>
*/
protected String getLock(long time)
{
try
{
return jobLockService.getLock(LOCK, time);
}
catch (LockAcquisitionException e)
{
return null;
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:AbstractBulkFilesystemImporter.java
示例7: acquireLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private synchronized String acquireLock(LockCallback lockCallback) throws LockAcquisitionException
{
// Try to get lock
String lockToken = jobLockService.getLock(LOCK_QNAME, LOCK_TTL);
// Got the lock - now register the refresh callback which will keep the lock alive
jobLockService.refreshLock(lockToken, LOCK_QNAME, LOCK_TTL, lockCallback);
if (logger.isDebugEnabled())
{
logger.debug("Lock acquired: " + LOCK_QNAME + ": "+ lockToken);
}
return lockToken;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:PostLookup.java
示例8: releaseLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private synchronized void releaseLock(LockCallback lockCallback, String lockToken)
{
try
{
if (lockCallback != null)
{
lockCallback.running.set(false);
}
if (lockToken != null )
{
jobLockService.releaseLock(lockToken, LOCK_QNAME);
if (logger.isDebugEnabled())
{
logger.debug("Lock released: " + LOCK_QNAME + ": " + lockToken);
}
}
}
catch (LockAcquisitionException e)
{
// Ignore
if (logger.isDebugEnabled())
{
logger.debug("Lock release failed: " + LOCK_QNAME + ": " + lockToken + "(" + e.getMessage() + ")");
}
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:PostLookup.java
示例9: acquireLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private String acquireLock(JobLockRefreshCallback lockCallback) throws LockAcquisitionException
{
// Try to get lock
String lockToken = jobLockService.getLock(LOCK_QNAME, LOCK_TTL);
// Got the lock - now register the refresh callback which will keep the lock alive
jobLockService.refreshLock(lockToken, LOCK_QNAME, LOCK_TTL, lockCallback);
if (logger.isDebugEnabled())
{
logger.debug("lock acquired: " + LOCK_QNAME + ": " + lockToken);
}
return lockToken;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:AbstractFeedGenerator.java
示例10: releaseLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private void releaseLock(LockCallback lockCallback, String lockToken)
{
try
{
if (lockCallback != null)
{
lockCallback.running.set(false);
}
if (lockToken != null)
{
jobLockService.releaseLock(lockToken, LOCK_QNAME);
if (logger.isDebugEnabled())
{
logger.debug("Lock released: " + LOCK_QNAME + ": " + lockToken);
}
}
}
catch (LockAcquisitionException e)
{
// Ignore
if (logger.isDebugEnabled())
{
logger.debug("Lock release failed: " + LOCK_QNAME + ": " + lockToken + "(" + e.getMessage() + ")");
}
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:AbstractFeedGenerator.java
示例11: getLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private String getLock(long time)
{
try
{
return jobLockService.getLock(lock, time);
}
catch (LockAcquisitionException e)
{
return null;
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:12,代码来源:SolrBackupClient.java
示例12: getLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private String getLock(long time)
{
try
{
return jobLockService.getLock(LOCK_QNAME, time);
}
catch (LockAcquisitionException e)
{
return null;
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:12,代码来源:UserUsageTrackingComponent.java
示例13: refreshLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
/**
* Helper method to refresh the current job's lock token
*/
protected void refreshLock() throws LockAcquisitionException
{
String token = this.lockToken.get();
if (token != null && !shutdownListener.isVmShuttingDown())
{
// We had a lock token AND the VM is still going
jobLockService.refreshLock(token, LOCK, LOCK_TTL);
}
else
{
// There is no lock token on this thread, so we trigger a deliberate failure
jobLockService.refreshLock("lock token not available", LOCK, LOCK_TTL);
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:AbstractNodeCleanupWorker.java
示例14: execute
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
public int execute()
{
String lockToken = null;
FixedAclUpdaterJobLockRefreshCallback jobLockRefreshCallback = new FixedAclUpdaterJobLockRefreshCallback();
try
{
lockToken = jobLockService.getLock(lockQName, lockTimeToLive, 0, 1);
jobLockService.refreshLock(lockToken, lockQName, lockRefreshTime, jobLockRefreshCallback);
AclWorkProvider provider = new AclWorkProvider();
AclWorker worker = new AclWorker();
BatchProcessor<NodeRef> bp = new BatchProcessor<>(
"FixedAclUpdater",
transactionService.getRetryingTransactionHelper(),
provider,
numThreads, maxItemBatchSize,
applicationContext,
log, 100);
int count = bp.process(worker, true);
return count;
}
catch (LockAcquisitionException e)
{
// already running
return 0;
}
finally
{
jobLockRefreshCallback.isActive.set(false);
if(lockToken != null)
{
jobLockService.releaseLock(lockToken, lockQName);
}
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:FixedAclUpdater.java
示例15: getLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
/**
* Attempts to get the lock. If the lock couldn't be taken, then <tt>null</tt> is returned.
*
* @return Returns the lock token or <tt>null</tt>
*/
private String getLock(long time)
{
try
{
return jobLockService.getLock(LOCK, time);
}
catch (LockAcquisitionException e)
{
return null;
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:ReEncryptor.java
示例16: testJobLocking
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
@Test
public void testJobLocking() throws Exception
{
HBBaseDataCollector simpleCollector = mock(HBBaseDataCollector.class);
when(simpleCollector.getCollectorId()).thenReturn("c1");
when(simpleCollector.getCronExpression()).thenReturn("0 0 0 ? * *");
// mock the job context
JobExecutionContext mockJobExecutionContext = mock(JobExecutionContext.class);
JobDetail jobDetail = new JobDetail();
when(mockJobExecutionContext.getJobDetail()).thenReturn(jobDetail);
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("collector", simpleCollector);
jobDataMap.put("hbDataSenderService", mockDataSenderService);
jobDataMap.put("jobLockService", mockJobLockService);
jobDetail.setJobDataMap(jobDataMap);
// Simulate job lock service
String lockToken = "token";
when(mockJobLockService.getLock(isA(QName.class), anyLong()))
.thenReturn(lockToken) // first job gets the lock
.thenThrow(new LockAcquisitionException("", "")); // second job doesn't get the lock
// Run two heart beat jobs
new HeartBeatJob().execute(mockJobExecutionContext);
new HeartBeatJob().execute(mockJobExecutionContext);
// Verify that the collector only collects data once, since only one job got the lock
verify(simpleCollector, Mockito.times(1)).collectData();
// Verify that data was passed to data sender
verify(mockDataSenderService, Mockito.times(1)).sendData(any(List.class));
verify(mockDataSenderService, Mockito.times(0)).sendData(any(HBData.class));
// Verify that both jobs tried to get the lock
verify(mockJobLockService, Mockito.times(2)).getLock(any(QName.class), anyLong());
// Verify that a callback was registered once
verify(mockJobLockService, Mockito.times(1)).refreshLock(eq(lockToken), any(QName.class),
anyLong(),
any(JobLockService.JobLockRefreshCallback.class));
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:HeartBeatJobTest.java
示例17: getExecutorLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
private String getExecutorLock()
{
String lockToken = null;
if (alfrescoJobExecutor.getJobExecutorLockEnabled())
{
try
{
lockToken = alfrescoJobExecutor.getJobLockService().getLock(LOCK_QNAME, jobLockTTL, 3000, 10);
if (logger.isTraceEnabled())
{
logger.trace(Thread.currentThread().getName() + " got lock token: " + lockToken);
}
}
catch (LockAcquisitionException e)
{
if (logger.isTraceEnabled())
{
logger.trace("Failed to get Alfresco Job Executor lock - may already running in another thread");
}
throw e;
}
}
return lockToken;
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:28,代码来源:AlfrescoJobExecutorThread.java
示例18: getLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
/**
* Attempts to get the lock. If the lock couldn't be taken, then <tt>null</tt> is returned.
*
* @return Returns the lock token or <tt>null</tt>
*/
private String getLock()
{
try
{
return jobLockService.getLock(getLockQName(), DEFAULT_TIME);
}
catch (LockAcquisitionException e)
{
return null;
}
}
开发者ID:Alfresco,项目名称:records-management-old,代码行数:17,代码来源:RecordsManagementJob.java
示例19: execute
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
public void execute(final JobExecutionContext jobexecutioncontext) throws JobExecutionException
{
final JobDataMap dataMap = jobexecutioncontext.getJobDetail().getJobDataMap();
final HBBaseDataCollector collector = (HBBaseDataCollector) dataMap.get(COLLECTOR_KEY);
final HBDataSenderService hbDataSenderService = (HBDataSenderService) dataMap.get(DATA_SENDER_SERVICE_KEY);
final JobLockService jobLockService = (JobLockService) dataMap.get(JOB_LOCK_SERVICE_KEY);
ParameterCheck.mandatory( COLLECTOR_KEY, collector);
ParameterCheck.mandatory(DATA_SENDER_SERVICE_KEY, hbDataSenderService);
ParameterCheck.mandatory(JOB_LOCK_SERVICE_KEY, jobLockService);
QName lockQname = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, collector.getCollectorId());
LockCallback lockCallback = new LockCallback(lockQname);
try
{
// Get lock
String lockToken = jobLockService.getLock(lockQname, LOCK_TTL);
// Register the refresh callback which will keep the lock alive.
// The lock will not be released manually,
// instead the job lock service will check the callback (running) flag every LOCK_TTL/2 ms from lock acquisition
// and release the lock when the flag is set to false.
jobLockService.refreshLock(lockToken, lockQname, LOCK_TTL, lockCallback);
if (logger.isDebugEnabled())
{
logger.debug("Lock acquired: " + lockQname + ": " + lockToken);
}
// Collect data and pass it to the data sender service
collectAndSendDataLocked(collector, hbDataSenderService);
}
catch (LockAcquisitionException e)
{
if (logger.isDebugEnabled())
{
logger.debug("Skipping collect and send data (could not get lock): " + e.getMessage());
}
}
finally
{
if (logger.isDebugEnabled())
{
logger.debug("Finished collector job. ID:" + collector.getCollectorId());
}
lockCallback.running.set(false);
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:49,代码来源:HeartBeatJob.java
示例20: acquireLock
import org.alfresco.repo.lock.LockAcquisitionException; //导入依赖的package包/类
/**
* Get a lock on the job.
* Tries every 5 seconds for 30 seconds, then
* every 30 seconds for half an hour.
*
* @throws LockAcquisitionException
*/
private void acquireLock()
{
try
{
// Quick try
lockToken = jobLockService.getLock(
replicationDef.getReplicationQName(),
replicationActionLockDuration,
5 * 1000, // Every 5 seconds
6 // 6 times = wait up to 30 seconds
);
active = true;
/**
* Got the lock - now register the refresh callback which will keep the
* lock alive
*/
jobLockService.refreshLock(
lockToken,
replicationDef.getReplicationQName(),
replicationActionLockDuration,
this
);
if(logger.isDebugEnabled())
{
logger.debug("lock aquired:" + replicationDef.getReplicationQName() );
}
}
catch(LockAcquisitionException e)
{
long retryTime = 30*1000;
int retries = (int)(60);
logger.debug(
"Unable to get the replication job lock on " +
replicationDef.getReplicationQName() +
", retrying every " + (int)(retryTime/1000) + " seconds"
);
active = true;
// Long try - every 30 seconds
lockToken = jobLockService.getLock(
replicationDef.getReplicationQName(),
replicationActionLockDuration,
retryTime,
retries
);
/**
* Got the lock - now register the refresh callback which will keep the
* lock alive
*/
jobLockService.refreshLock(
lockToken,
replicationDef.getReplicationQName(),
replicationActionLockDuration,
this
);
if(logger.isDebugEnabled())
{
logger.debug("lock aquired (from long timeout):" + replicationDef.getReplicationQName() );
}
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:76,代码来源:ReplicationActionExecutor.java
注:本文中的org.alfresco.repo.lock.LockAcquisitionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论