@Override public Status delete(String table, String recordKey) { String compositKey = createKey(table, recordKey); try { cache().remove(compositKey); return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } }
@Override public Status update(String table, String recordKey, Map<String, ByteIterator> values) { String compositKey = createKey(table, recordKey); try { Map<String, String> stringValues = new HashMap<>(); StringByteIterator.putAllAsStrings(stringValues, values); cache().put(compositKey, stringValues); return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } }
@Override public Status insert(String table, String recordKey, Map<String, ByteIterator> values) { String compositKey = createKey(table, recordKey); Map<String, String> stringValues = new HashMap<>(); StringByteIterator.putAllAsStrings(stringValues, values); try { cache().put(compositKey, stringValues); return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } }
@Override public Status read(String table, String recordKey, Set<String> fields, Map<String, ByteIterator> result) { String compositKey = createKey(table, recordKey); try { Map<String, String> values = cache().get(compositKey); if (values == null || values.isEmpty()) { return Status.NOT_FOUND; } if (fields == null) { //get all field/value pairs StringByteIterator.putAllAsByteIterators(result, values); } else { for (String field : fields) { String value = values.get(field); if (value != null) { result.put(field, new StringByteIterator(value)); } } } return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } }
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { try { Map<String, String> row; if (clustered) { row = AtomicMapLookup.getAtomicMap(infinispanManager.getCache(table), key, false); } else { Cache<String, Map<String, String>> cache = infinispanManager.getCache(table); row = cache.get(key); } if (row != null) { result.clear(); if (fields == null || fields.isEmpty()) { StringByteIterator.putAllAsByteIterators(result, row); } else { for (String field : fields) { result.put(field, new StringByteIterator(row.get(field))); } } } return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } }
public Status delete(String table, String key) { try { if (clustered) { AtomicMapLookup.removeAtomicMap(infinispanManager.getCache(table), key); } else { infinispanManager.getCache(table).remove(key); } return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } } }
public Status insert(String table, String key, Map<String, ByteIterator> values) { try { if (clustered) { AtomicMap<String, String> row = AtomicMapLookup.getAtomicMap(infinispanManager.getCache(table), key); row.clear(); StringByteIterator.putAllAsStrings(row, values); } else { infinispanManager.getCache(table).put(key, values); } return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } }
public Status update(String table, String key, Map<String, ByteIterator> values) { try { if (clustered) { AtomicMap<String, String> row = AtomicMapLookup.getAtomicMap(infinispanManager.getCache(table), key); StringByteIterator.putAllAsStrings(row, values); } else { Cache<String, Map<String, String>> cache = infinispanManager.getCache(table); Map<String, String> row = cache.get(key); if (row == null) { row = StringByteIterator.getStringMap(values); cache.put(key, row); } else { StringByteIterator.putAllAsStrings(row, values); } } return Status.OK; } catch (Exception e) { LOGGER.error(e); return Status.ERROR; } }
public static void sleepThread(long sleeptime, String messageOnInterrupt) { try { Thread.sleep(sleeptime); } catch (InterruptedException ie) { if (messageOnInterrupt != null) log.error(messageOnInterrupt); } }
private static void sleepThreadInt(long sleeptime, String messageOnInterrupt) throws InterruptedException { try { Thread.sleep(sleeptime); } catch (InterruptedException ie) { if (messageOnInterrupt != null) log.error(messageOnInterrupt); throw ie; } }
private void failed(Exception e) { log.error(e); if (! KEEP_GOING) { failed.set(true); } }
@Override public void close() { try { invoker.broadcast(ClusteredQueryCommand.destroyLazyQuery(cache, queryId)); } catch (Exception e) { log.error("Could not close the distributed iterator", e); } }
public void stopBlocking() { if (exception != null) { throw exception; } if (!queuedTopologies.isEmpty()) { log.error("Stopped blocking topology updates, but there are " + queuedTopologies.size() + " blocked updates in the queue: " + queuedTopologies); } enabled = false; log.debugf("Stopped blocking topology updates"); }
@Override public void close() { ClusteredQueryCommand killQuery = ClusteredQueryCommand.destroyLazyQuery(cache, queryId); ClusteredQueryInvoker invoker = new ClusteredQueryInvoker(cache, asyncExecutor); try { invoker.broadcast(killQuery); } catch (Exception e) { log.error("Could not close the distributed iterator", e); } }
protected void nullOutFields() { // TestNG keeps test instances in memory forever, make them leaner by clearing direct references to caches for (Field field : getAllFields()) { if (!Modifier.isFinal(field.getModifiers()) && fieldIsMemoryHog(field)) { field.setAccessible(true); try { field.set(this, null); } catch (IllegalArgumentException | IllegalAccessException e) { log.error(e); } } } }
@AfterClass(alwaysRun=true) protected void destroyAfterClass() { try { if (cleanupAfterTest()) teardown(); } catch (Exception e) { log.error("Unexpected!", e); } }
@BeforeClass(alwaysRun = true) protected void createBeforeClass() throws Exception { try { if (cleanupAfterTest()) setup(); else assert cleanupAfterMethod() : "you must either cleanup after test or after method"; } catch (Exception e) { log.error("Unexpected!", e); throw e; } }
@BeforeMethod(alwaysRun = true) protected void createBeforeMethod() throws Exception { try { if (cleanupAfterMethod()) setup(); else assert cleanupAfterTest() : "you must either cleanup after test or after method"; } catch (Exception e) { log.error("Unexpected!", e); throw e; } }
@Override public void run() { try { for (int i = 0; i < 100; i++) writer.write(new MarshalledEntryImpl(k(m, i), v(m, i), null, marshaller())); } catch (Exception e) { log.error("Error storing entry", e); } done.countDown(); } };
private void callCreateCacheManagers() throws Throwable { try { log.debug("Creating cache managers"); createCacheManagers(); log.debug("Cache managers created, ready to start the test"); } catch (Throwable th) { log.error("Error in test setup: ", th); throw th; } }