public void deleteQuiet(String... files) { ensureOpen(); StoreDirectory directory = this.directory; for (String file : files) { try { directory.deleteFile("Store.deleteQuiet", file); } catch (Exception ex) { // ignore :( } } }
public StoreStats stats() throws IOException { ensureOpen(); return new StoreStats(directory.estimateSize()); }
/** Estimate the cumulative size of all files in this directory in bytes. */ long estimateSize() throws IOException { return ((ByteSizeCachingDirectory) getDelegate()).estimateSizeInBytes(); }
private void readAndCompareChecksum() throws IOException { actualChecksum = digestToString(getChecksum()); if (!metadata.checksum().equals(actualChecksum)) { throw new CorruptIndexException("checksum failed (hardware problem?) : expected=" + metadata.checksum() + " actual=" + actualChecksum + " (resource=" + metadata.toString() + ")", "VerifyingIndexOutput(" + metadata.name() + ")"); } }
public IndexInput openVerifyingInput(String filename, IOContext context, StoreFileMetaData metadata) throws IOException { assert metadata.writtenBy() != null; return new VerifyingIndexInput(directory().openInput(filename, context)); }
public long verify() throws CorruptIndexException { long storedChecksum = getStoredChecksum(); if (getChecksum() == storedChecksum) { return storedChecksum; } throw new CorruptIndexException("verification failed : calculated=" + Store.digestToString(getChecksum()) + " stored=" + Store.digestToString(storedChecksum), this); }
/** * File length * * @return file length */ public long length() { return metadata.length(); }
private void completeIndexAttributes(ProtobufSystemInfo.Section.Builder protobuf) { IndicesStatsResponse indicesStats = esClient.prepareStats().all().get(); for (Map.Entry<String, IndexStats> indexStats : indicesStats.getIndices().entrySet()) { String prefix = "Index " + indexStats.getKey() + " - "; setAttribute(protobuf, prefix + "Docs", indexStats.getValue().getPrimaries().getDocs().getCount()); setAttribute(protobuf, prefix + "Shards", indexStats.getValue().getShards().length); setAttribute(protobuf, prefix + "Store Size", byteCountToDisplaySize(indexStats.getValue().getPrimaries().getStore().getSizeInBytes())); } } }
/** * Returns file md5 checksum provided by {@link org.elasticsearch.index.store.Store} * * @return file checksum */ public String checksum() { return metadata.checksum(); }
/** * Returns original file name * * @return original file name */ public String physicalName() { return metadata.name(); }
public static void verify(IndexOutput output) throws IOException { if (output instanceof VerifyingIndexOutput) { ((VerifyingIndexOutput) output).verify(); } }
/** * The shard store class that should be used for each shard. */ public DirectoryService newDirectoryService(ShardPath path) { return new FsDirectoryService(indexSettings, this, path); }
/** * Checks if a file in a store is the same file * * @param md file in a store * @return true if file in a store this this file have the same checksum and length */ public boolean isSame(StoreFileMetaData md) { return metadata.isSame(md); }
/** * @return commit sync id if exists, else null */ public String syncId() { return metadataSnapshot.getSyncId(); }
public static void verify(IndexInput input) throws IOException { if (input instanceof VerifyingIndexInput) { ((VerifyingIndexInput) input).verify(); } }
public static boolean checkIntegrityNoException(StoreFileMetaData md, Directory directory) { try { checkIntegrity(md, directory); return true; } catch (IOException e) { return false; } }
LuceneVerifyingIndexOutput(StoreFileMetaData metadata, IndexOutput out) { super(out); this.metadata = metadata; checksumPosition = metadata.length() - 8; // the last 8 bytes are the checksum - we store it in footerChecksum }
private long getIndexSize(){ long indexSize = 0L; final String indexName = indexLocationStrategy.getIndexInitialName(); try { final IndicesStatsResponse statsResponse = esProvider.getClient() .admin() .indices() .prepareStats(indexName) .all() .execute() .actionGet(); final CommonStats indexStats = statsResponse.getIndex(indexName).getTotal(); indexSize = indexStats.getStore().getSizeInBytes(); } catch (IndexMissingException e) { // if for some reason the index size does not exist, // log an error and we can assume size is 0 as it doesn't exist logger.error("Unable to get size for index {} due to IndexMissingException for app {}", indexName, indexLocationStrategy.getApplicationScope().getApplication().getUuid()); } return indexSize; }
public static void toProtobuf(NodeStats stats, ProtobufSystemInfo.Section.Builder protobuf) { setAttribute(protobuf, "CPU Usage (%)", stats.getProcess().getCpu().getPercent()); setAttribute(protobuf, "Disk Available", byteCountToDisplaySize(stats.getFs().getTotal().getAvailable().getBytes())); setAttribute(protobuf, "Store Size", byteCountToDisplaySize(stats.getIndices().getStore().getSizeInBytes())); setAttribute(protobuf, "Open File Descriptors", stats.getProcess().getOpenFileDescriptors()); setAttribute(protobuf, "Max File Descriptors", stats.getProcess().getMaxFileDescriptors()); setAttribute(protobuf, "Spinning", stats.getFs().getTotal().getSpins()); setAttribute(protobuf, "JVM Heap Usage", formatPercent(stats.getJvm().getMem().getHeapUsedPercent())); setAttribute(protobuf, "JVM Heap Used", byteCountToDisplaySize(stats.getJvm().getMem().getHeapUsed().getBytes())); setAttribute(protobuf, "JVM Heap Max", byteCountToDisplaySize(stats.getJvm().getMem().getHeapMax().getBytes())); setAttribute(protobuf, "JVM Non Heap Used", byteCountToDisplaySize(stats.getJvm().getMem().getNonHeapUsed().getBytes())); setAttribute(protobuf, "JVM Threads", stats.getJvm().getThreads().getCount()); setAttribute(protobuf, "Field Data Memory", byteCountToDisplaySize(stats.getIndices().getFieldData().getMemorySizeInBytes())); setAttribute(protobuf, "Field Data Circuit Breaker Limit", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.FIELDDATA).getLimit())); setAttribute(protobuf, "Field Data Circuit Breaker Estimation", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.FIELDDATA).getEstimated())); setAttribute(protobuf, "Request Circuit Breaker Limit", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.REQUEST).getLimit())); setAttribute(protobuf, "Request Circuit Breaker Estimation", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.REQUEST).getEstimated())); setAttribute(protobuf, "Query Cache Memory", byteCountToDisplaySize(stats.getIndices().getQueryCache().getMemorySizeInBytes())); setAttribute(protobuf, "Request Cache Memory", byteCountToDisplaySize(stats.getIndices().getRequestCache().getMemorySizeInBytes())); }