/** * Loads the model from the location that it saves to */ @Override public <E> E load(Class<E> clazz) { return SerializationUtils.readObject(file); } }
@Override public E poll() { String path = paths.poll(); E ret = SerializationUtils.readObject(new File(path)); File item = new File(path); item.delete(); return ret; }
@Override public synchronized Job load(String id) throws Exception { String path = paths.remove(id); if(path == null) { log.warn("Tried loading work from id " + id + " but path was null"); return null; } File load = new File(path); Job u = SerializationUtils.readObject(load); load.deleteOnExit(); return u; }
/** * Loads the data applyTransformToDestination * * @param worker the worker to load for * @return the data for the given worker or null */ @Override public Job load(String worker) { File f = workerData.get(worker) != null ? new File(workerData.get(worker)) : null; if(f == null || !f.exists()) return null; Job d = SerializationUtils.readObject(f); workerData.remove(f); f.delete(); return d; }
@Override public void save(String id,Job save) throws Exception { if(save == null) throw new IllegalArgumentException("Saving null network not allowed"); if(updateableIMap != null) { updateableIMap.put(id,save); } else { File saveFile = new File(baseDir,id); SerializationUtils.saveObject(save,saveFile); boolean loadedProperly = false; while(!loadedProperly) { try { SerializationUtils.readObject(saveFile); }catch(Exception e) { } loadedProperly = true; } paths.put(id,saveFile.getAbsolutePath()); } } }