public static String ser(Object obj) throws JSONSerDeException { try { return mapper.writeValueAsString(obj); } catch (JsonGenerationException e) { throw new JSONSerDeException(e); } catch (JsonMappingException e) { throw new JSONSerDeException(e); } catch (IOException e) { throw new JSONSerDeException(e); } }
@Override public String abortDeploy(long version) throws DNodeException { try { synchronized (deployLock) { // No new deploys to be handled until we // cancel the current one Future<?> future = deploysBeingExecuted.get(version); if (future == null) { return JSONSerDe.ser(new DNodeStatusResponse("Not deployment running with version["+version+"]")); } future.cancel(true); return JSONSerDe.ser(new DNodeStatusResponse("status[OK]. Deploy with version["+version+"] cancelled.")); } } catch (JSONSerDeException e) { unexpectedException(e); throw new DNodeException(EXCEPTION_UNEXPECTED, e.getMessage()); } }
} catch (JSONSerDeException e) { unexpectedException(e); throw new DNodeException(EXCEPTION_UNEXPECTED, e.getMessage());
@Override public String deleteOldVersions(List<com.splout.db.thrift.TablespaceVersion> versions) throws DNodeException { for (com.splout.db.thrift.TablespaceVersion version : versions) { log.info("Going to remove " + version + " as I have been told to do so."); try { deleteLocalVersion(version); } catch (Throwable e) { unexpectedException(e); throw new DNodeException(EXCEPTION_UNEXPECTED, e.getMessage()); } } try { // Publish new DNodeInfo in distributed registry. // This makes QNodes notice that a new version is available... // PartitionMap and ReplicationMap will be built incrementally as DNodes // finish. dnodesRegistry.changeInfo(new DNodeInfo(config)); return JSONSerDe.ser(new DNodeStatusResponse("Ok. Delete old versions executed.")); } catch (JSONSerDeException e) { unexpectedException(e); throw new DNodeException(EXCEPTION_UNEXPECTED, e.getMessage()); } }
/** * Thrift RPC method -> Given a list of {@link RollbackAction}s, perform a * synchronous rollback */ @Override public String rollback(List<RollbackAction> rollbackActions, String ignoreMe) throws DNodeException { // The DNode doesn't need to do anything special for rolling back a version. // It can serve any version that is stored locally. try { return JSONSerDe.ser(new DNodeStatusResponse("Ok. Rollback order received.")); } catch (JSONSerDeException e) { unexpectedException(e); throw new DNodeException(EXCEPTION_UNEXPECTED, e.getMessage()); } }
public static <T> T deSer(String str, Class<T> clazz) throws JSONSerDeException { try { return (T) mapper.readValue(str, clazz); } catch(JsonParseException e) { throw new JSONSerDeException(e); } catch(JsonMappingException e) { throw new JSONSerDeException(e); } catch(IOException e) { throw new JSONSerDeException(e); } } }
public static String ser(Object obj) throws JSONSerDeException { try { return mapper.writeValueAsString(obj); } catch(JsonGenerationException e) { throw new JSONSerDeException(e); } catch(JsonMappingException e) { throw new JSONSerDeException(e); } catch(IOException e) { throw new JSONSerDeException(e); } }
@SuppressWarnings("unchecked") public static <T> T deSer(String str, TypeReference<T> ref) throws JSONSerDeException { try { return (T) mapper.readValue(str, ref); } catch (JsonParseException e) { throw new JSONSerDeException(e); } catch (JsonMappingException e) { throw new JSONSerDeException(e); } catch (IOException e) { throw new JSONSerDeException(e); } }
@SuppressWarnings("unchecked") public static <T> T deSer(String str, TypeReference<T> ref) throws JSONSerDeException { try { return (T) mapper.readValue(str, ref); } catch(JsonParseException e) { throw new JSONSerDeException(e); } catch(JsonMappingException e) { throw new JSONSerDeException(e); } catch(IOException e) { throw new JSONSerDeException(e); } }
public static <T> T deSer(String str, Class<T> clazz) throws JSONSerDeException { try { return (T) mapper.readValue(str, clazz); } catch (JsonParseException e) { throw new JSONSerDeException(e); } catch (JsonMappingException e) { throw new JSONSerDeException(e); } catch (IOException e) { throw new JSONSerDeException(e); } } }