Created
November 30, 2011 21:51
-
-
Save johndemic/1411118 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Integer getFailureCount() { | |
try { | |
objectStoreMutex.acquire(); | |
} catch (InterruptedException e) { | |
logger.error("Could not acquire mutex", e); | |
} | |
ObjectStore objectStore = objectStoreManager.getObjectStore(MuleProperties.OBJECT_STORE_DEFAULT_PERSISTENT_NAME); | |
String key = String.format("%s.failureCount", breakerName); | |
Integer failureCount = 0; | |
try { | |
if (objectStore.contains(key)) { | |
failureCount = (Integer) objectStore.retrieve(key); | |
} | |
} catch (Exception e) { | |
logger.error("Could not retrieve key from object-store: " + key, e); | |
} | |
objectStoreMutex.release(); | |
return failureCount; | |
} | |
void incrementFailureCount() { | |
try { | |
objectStoreMutex.acquire(); | |
} catch (InterruptedException e) { | |
logger.error("Could not acquire mutex", e); | |
} | |
ObjectStore objectStore = objectStoreManager.getObjectStore(MuleProperties.OBJECT_STORE_DEFAULT_PERSISTENT_NAME); | |
String key = String.format("%s.failureCount", breakerName); | |
Integer failureCount = 0; | |
try { | |
if (objectStore.contains(key)) { | |
failureCount = (Integer) objectStore.retrieve(key); | |
objectStore.remove(key); | |
} | |
objectStore.store(key, failureCount + 1); | |
} catch (Exception e) { | |
logger.error("Could not retrieve key from object-store: " + key, e); | |
} | |
objectStoreMutex.release(); | |
} | |
void resetFailureCount() { | |
try { | |
objectStoreMutex.acquire(); | |
} catch (InterruptedException e) { | |
logger.error("Could not acquire mutex", e); | |
} | |
ObjectStore objectStore = objectStoreManager.getObjectStore(MuleProperties.OBJECT_STORE_DEFAULT_PERSISTENT_NAME); | |
String key = String.format("%s.failureCount", breakerName); | |
Integer failureCount = 0; | |
try { | |
if (objectStore.contains(key)) { | |
failureCount = (Integer) objectStore.retrieve(key); | |
objectStore.remove(key); | |
} | |
objectStore.store(key, 0); | |
} catch (Exception e) { | |
logger.error("Could not retrieve key from object-store: " + key, e); | |
} | |
objectStoreMutex.release(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment