void archiveCorruptIndexFiles(File directory) { File newDirectory = new File(new File(getHost().getStorageSandbox()), this.indexDirectory + "." + Utils.getNowMicrosUtc()); try { logWarning("Archiving corrupt index files to %s", newDirectory.toPath()); Files.createDirectory(newDirectory.toPath()); // we assume a flat directory structure for the LUCENE directory FileUtils.moveOrDeleteFiles(directory, newDirectory, false); } catch (IOException e) { logWarning(e.toString()); } }
public void updateMemoryAndDiskInfo() { Runtime r = Runtime.getRuntime(); this.info.freeMemoryByteCount = r.freeMemory(); this.info.totalMemoryByteCount = r.totalMemory(); this.info.maxMemoryByteCount = r.maxMemory(); try { URI sandbox = getStorageSandbox(); if (sandbox == null) { throw new RuntimeException("Sandbox not set"); } File f = new File(sandbox); this.info.freeDiskByteCount = f.getFreeSpace(); this.info.usableDiskByteCount = f.getUsableSpace(); this.info.totalDiskByteCount = f.getTotalSpace(); } catch (Exception e) { log(Level.WARNING, "Exception getting disk usage: %s", Utils.toString(e)); } }
/** * Infrastructure use. Copies the specified file URL to the resource file path */ public Path copyResourceToSandbox(URL url, Path resourcePath) throws URISyntaxException { File sandbox = new File(getStorageSandbox()); Path outputPath = sandbox.toPath().resolve(DEFAULT_RESOURCE_SANDBOX_DIR) .resolve(resourcePath); // Return reference to file if possible. // This is not possible when the resource is embedded in a JAR. if (url.getProtocol().equals("file")) { log(Level.FINE, "Using resource %s", url.getPath()); URI uri = url.toURI(); return Paths.get(uri); } try { log(Level.FINE, "Copying resource %s to %s", url, outputPath); Path parent = outputPath.getParent(); if (parent == null) { throw new IOException("No parent for output path: " + outputPath); } Files.createDirectories(parent); InputStream is = url.openStream(); Files.copy(is, outputPath, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { log(Level.WARNING, "Unable to copy resource %s to %s: %s", url, outputPath, e.toString()); return null; } return outputPath; }
private Map<String, LoaderServiceInfo> loadFromFileSystem(LoaderServiceState state) throws ClassNotFoundException, InstantiationException, IllegalAccessException { File libDir = new File(state.path); if (!libDir.isAbsolute()) { libDir = new File(new File(getHost().getStorageSandbox()), state.path); } if (!libDir.exists()) { if (!libDir.mkdirs()) { logFine("Failed to pre-create the Loader path directory %s", libDir); return null; } } else if (!libDir.isDirectory()) { logFine("Loader path %s is not a directory.", libDir.getAbsolutePath()); return null; } Map<String, LoaderServiceInfo> services = discoverServices(libDir, state.servicePackages); if (services != null) { startDiscoveredServices(services, state); } return services; }
boolean isInMemoryIndex = indexInfo.indexDirectory == null; URI storageSandbox = getHost().getStorageSandbox();
File directory = new File(new File(getHost().getStorageSandbox()), this.indexDirectory); Stream<Path> stream = null; long count;
restoreTo = Paths.get(getHost().getStorageSandbox()).resolve(indexInfo.indexDirectory);
File directory = new File(new File(getHost().getStorageSandbox()), this.indexDirectory); for (int retryCount = 0; retryCount < 2; retryCount++) { try {
static ServiceHost createAndStartHost(String... args) throws Throwable { ServiceHost host = ServiceHost.create(args); host.start(); host.startDefaultCoreServicesSynchronously(); host.startService(new RootNamespaceService()); host.startFactory(new UpgradeDemoEmployeeService()); // In order to support upgrading your Xenon application, you need to start the MigrationTaskService host.startFactory(new MigrationTaskService()); // Added for 'add-logging' project. host.log(Level.INFO, "Starting host [add-logging] with args these args:%n[id=%s]%n[port=%d]%n[sandbox=%s]%n[peerNodes=%s]", host.getId(), host.getPort(), host.getStorageSandbox(), host.getInitialPeerHosts()); return host; }
static ServiceHost createAndStartHost(String... args) throws Throwable { ServiceHost host = ServiceHost.create(args); host.start(); host.startDefaultCoreServicesSynchronously(); host.startService(new RootNamespaceService()); host.startFactory(new UpgradeDemoEmployeeService()); // In order to support upgrading your Xenon application, you need to start the MigrationTaskService host.startFactory(new MigrationTaskService()); host.startService(new UpgradeDemoEmployeeServiceTransformService()); host.log(Level.INFO, "Starting host [add-logging] with args these args:%n[id=%s]%n[port=%d]%n[sandbox=%s]%n[peerNodes=%s]", host.getId(), host.getPort(), host.getStorageSandbox(), host.getInitialPeerHosts()); return host; }
this.state.httpPort); configureLogging(new File(getStorageSandbox()));