How to use getMutex method of com.paypal.selion.grid.servlets.transfer.ManagedArtifactRepository class

Best SeLion code snippet using com.paypal.selion.grid.servlets.transfer.ManagedArtifactRepository.getMutex

Source:ManagedArtifactRepository.java Github

copy

Full Screen

...81 // of adding a new parameter into the config files and reading it in here?82 timer.scheduleAtFixedRate(new RepositoryCleaner(), 60 * 60 * 1000, 60 * 60 * 1000);83 }84 public ManagedArtifact saveContents(UploadedArtifact uploadedArtifact) {85 synchronized (getMutex(uploadedArtifact)) {86 LOGGER.entering(uploadedArtifact);87 File file = createFileUsing(uploadedArtifact);88 try {89 FileUtils.writeByteArrayToFile(file, uploadedArtifact.getArtifactContents());90 ManagedArtifact managedArtifact = getManagedArtifact(file.getAbsolutePath());91 LOGGER.exiting(managedArtifact);92 return managedArtifact;93 } catch (IOException e) {94 throw new ArtifactUploadException("IOException in writing file contents", e);95 }96 }97 }98 public ManagedArtifact getArtifact(String pathInfo) {99 LOGGER.entering(pathInfo);100 try {101 repositorySynchronizationLock.lock();102 ManagedArtifact managedArtifact = getMatchedArtifact(pathInfo);103 if (managedArtifact.isExpired()) {104 throw new ArtifactDownloadException("The requested artifact: " + managedArtifact.getArtifactName()105 + " has expired");106 }107 LOGGER.exiting(managedArtifact);108 return managedArtifact;109 } finally {110 repositorySynchronizationLock.unlock();111 }112 }113 private String getMutex(UploadedArtifact uploadedArtifact) {114 StringBuilder buffer = new StringBuilder();115 for (String s : uploadedArtifact.getMetaInfo().keySet()) {116 buffer.append(s);117 }118 return buffer.toString().intern();119 }120 private ManagedArtifact getMatchedArtifact(String pathInfo) {121 List<File> files = (List<File>) FileUtils.listFiles(repoFolder, TrueFileFilter.INSTANCE,122 TrueFileFilter.INSTANCE);123 for (File file : files) {124 ManagedArtifact managedArtifact = getManagedArtifact(file.getAbsolutePath());125 if (managedArtifact.matchesPathInfo(pathInfo)) {126 return managedArtifact;127 }...

Full Screen

Full Screen

getMutex

Using AI Code Generation

copy

Full Screen

1 def getMutex = ManagedArtifactRepository.getMutex()2 def lock = getMutex.lock()3 def unlock = getMutex.unlock()4 def tryLock = getMutex.tryLock()5 def tryLockWithTimeout = getMutex.tryLock(1, TimeUnit.SECONDS)6 def isLocked = getMutex.isLocked()7 def newCondition = getMutex.newCondition()8 def await = newCondition.await()9 def awaitWithTimeout = newCondition.await(1, TimeUnit.SECONDS)10 def awaitWithTimeoutAndTimeUnit = newCondition.await(1, TimeUnit.SECONDS)11 def awaitNanos = newCondition.awaitNanos(1)12 def awaitUninterruptibly = newCondition.awaitUninterruptibly()

Full Screen

Full Screen

getMutex

Using AI Code Generation

copy

Full Screen

1private static final String LOCK_PATH = "/lock";2private static final String LOCK_NAME = "artifactRepositoryLock";3private static final String LOCK_EXTENSION = ".lock";4public synchronized static void getLock() {5 try {6 getMutex().acquire();7 } catch (Exception e) {8 e.printStackTrace();9 }10}11public synchronized static void releaseLock() {12 try {13 getMutex().release();14 } catch (Exception e) {15 e.printStackTrace();16 }17}18private static InterProcessMutex getMutex() {19 if (mutex == null) {20 InterProcessMutex mutex = new InterProcessMutex(getClient(), LOCK_PATH + "/" + LOCK_NAME + LOCK_EXTENSION);21 }22 return mutex;23}24private static CuratorFramework getClient() {25 if (client == null) {26 client = CuratorFrameworkFactory.newClient("localhost:2181", new RetryOneTime(1000));27 client.start();28 }29 return client;30}31public void test1() {32 getLock();33 releaseLock();34}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful