backupDir, snapshotName, prefixName + "-" + type.name() + ".db"); componentPath.getParent().toFile().mkdirs(); try (FileWriter fileWriter = new FileWriter(componentPath.toFile())) {
Type type = Type.fromRepresentation(path.right);
Type type = Type.fromRepresentation(path.right);
Type type = Type.fromRepresentation(path.right);
/** * Filename of the form "<ksname>/<cfname>-[tmp-][<version>-]<gen>-<component>", * @return A Descriptor for the SSTable, and a Component for this particular file. * TODO move descriptor into Component field */ public static Pair<Descriptor,Component> fromFilename(File directory, String name) { Pair<Descriptor,String> path = Descriptor.fromFilename(directory, name); // parse the component suffix Type type = Type.fromRepresentation(path.right); // build (or retrieve singleton for) the component object Component component; switch(type) { case DATA: component = Component.DATA; break; case PRIMARY_INDEX: component = Component.PRIMARY_INDEX; break; case FILTER: component = Component.FILTER; break; case COMPRESSION_INFO: component = Component.COMPRESSION_INFO; break; case STATS: component = Component.STATS; break; case DIGEST: component = Component.DIGEST; break; case CRC: component = Component.CRC; break; case SUMMARY: component = Component.SUMMARY; break; case TOC: component = Component.TOC; break; case CUSTOM: component = new Component(Type.CUSTOM, path.right); break; default: throw new IllegalStateException(); } return Pair.create(path.left, component); }
/** * Reads the list of components from the TOC component. * @return set of components found in the TOC */ protected static Set<Component> readTOC(Descriptor descriptor) throws IOException { File tocFile = new File(descriptor.filenameFor(Component.TOC)); //List<String> componentNames = Files.readLines(tocFile, Charset.defaultCharset()); List<String> componentNames = readLines(tocFile); Set<Component> components = Sets.newHashSetWithExpectedSize(componentNames.size()); for (String componentName : componentNames) { Component component = new Component(Component.Type.fromRepresentation(componentName), componentName); try(ChannelProxy proxy = ChannelProxy.getInstance(descriptor.filenameFor(component))) { if (!proxy.exists()) logger.error("Missing component: {}", descriptor.filenameFor(component)); else components.add(component); } } return components; }
/** * Reads the list of components from the TOC component. * @return set of components found in the TOC */ protected static Set<Component> readTOC(Descriptor descriptor) throws IOException { File tocFile = new File(descriptor.filenameFor(Component.TOC)); List<String> componentNames = Files.readLines(tocFile, Charset.defaultCharset()); Set<Component> components = Sets.newHashSetWithExpectedSize(componentNames.size()); for (String componentName : componentNames) { Component component = new Component(Component.Type.fromRepresentation(componentName), componentName); if (!new File(descriptor.filenameFor(component)).exists()) logger.error("Missing component: {}", descriptor.filenameFor(component)); else components.add(component); } return components; }
/** * Reads the list of components from the TOC component. * @return set of components found in the TOC */ protected static Set<Component> readTOC(Descriptor descriptor) throws IOException { File tocFile = new File(descriptor.filenameFor(Component.TOC)); List<String> componentNames = Files.readLines(tocFile, Charset.defaultCharset()); Set<Component> components = Sets.newHashSetWithExpectedSize(componentNames.size()); for (String componentName : componentNames) { Component component = new Component(Component.Type.fromRepresentation(componentName), componentName); if (!new File(descriptor.filenameFor(component)).exists()) logger.error("Missing component: {}", descriptor.filenameFor(component)); else components.add(component); } return components; }
/** * Reads the list of components from the TOC component. * @return set of components found in the TOC */ protected static Set<Component> readTOC(Descriptor descriptor) throws IOException { File tocFile = new File(descriptor.filenameFor(Component.TOC)); List<String> componentNames = Files.readLines(tocFile, Charset.defaultCharset()); Set<Component> components = Sets.newHashSetWithExpectedSize(componentNames.size()); for (String componentName : componentNames) { Component component = new Component(Component.Type.fromRepresentation(componentName), componentName); if (!new File(descriptor.filenameFor(component)).exists()) logger.error("Missing component: {}", descriptor.filenameFor(component)); else components.add(component); } return components; }
/** * Reads the list of components from the TOC component. * @return set of components found in the TOC */ protected static Set<Component> readTOC(Descriptor descriptor) throws IOException { File tocFile = new File(descriptor.filenameFor(Component.TOC)); List<String> componentNames = Files.readLines(tocFile, Charset.defaultCharset()); Set<Component> components = Sets.newHashSetWithExpectedSize(componentNames.size()); for (String componentName : componentNames) { Component component = new Component(Component.Type.fromRepresentation(componentName), componentName); if (!new File(descriptor.filenameFor(component)).exists()) logger.error("Missing component: {}", descriptor.filenameFor(component)); else components.add(component); } return components; }