public void remove(String instanceId, String bagName) throws JasDBStorageException { File writerPath = getWriterPath(instanceId, bagName); RecordWriter recordWriter = recordWriters.get(writerPath.toString()); recordWriter.closeWriter(); File indexLocation = new File(removeExtension(writerPath.toString()) + ".idx"); deleteSafely(indexLocation); deleteSafely(writerPath); recordWriters.remove(writerPath.toString()); }
public static String resolveResourcePath(String resourcePath) { if(resourcePath.startsWith("classpath:")) { String strippedPath = resourcePath.replace("classpath:", ""); return loadResource(strippedPath).toString(); } else { return resourcePath; } }
public TransactionalRecordWriter(File recordLocation) { this.indexLocation = new File(FileUtils.removeExtension(recordLocation.toString()) + ".idx"); this.writer = new FSWriter(recordLocation); }
private void handleCreateNewPidFile() throws JasDBStorageException { File pidFile = new File(datastoreLocation, PID_FILE); lastShutdownClean = !pidFile.exists(); LOG.info("Last shutdown clean: {}", lastShutdownClean); try { if(datastoreLocation.exists() || datastoreLocation.mkdirs()) { FileUtils.writeToFile(pidFile, "JasDB Instance Started, " + PID); LOG.info("Created JasDB pid file: {}", pidFile); } else { throw new JasDBStorageException("Unable to create database path, directories could not be created: " + datastoreLocation) ; } } catch(IOException e) { throw new JasDBStorageException("Unable to open JasDB metadata store, pid file: " + pidFile.toString() + " could not be created"); } }