List of usage examples for javax.imageio.stream FileImageInputStream readInt
public int readInt() throws IOException
From source file:de.hpi.fgis.hdrs.node.Index.java
void readMeta() throws IOException { File metaFile = new File(indexRoot.getAbsolutePath() + File.separator + METAFILE); if (!metaFile.isFile()) { throw new IOException("Index meta file not found for index " + order); }//www. j a v a2s .c om segments.clear(); FileImageInputStream in = new FileImageInputStream(metaFile); int size = in.readInt(); for (int i = 0; i < size; ++i) { SegmentInfo info = SegmentInfo.read(in); segments.add(info); } in.close(); }
From source file:de.hpi.fgis.hdrs.node.Node.java
boolean initialize() { // read segment id counter File storemeta = new File(rootDir.getAbsolutePath() + File.separator + SEGMENT_ID_COUNTER_FILE); if (storemeta.isFile()) { FileImageInputStream in; try {//from ww w. j av a 2 s. c om in = new FileImageInputStream(storemeta); segmentIdCounter = in.readInt(); in.close(); } catch (IOException ex) { LOG.fatal("error while reading store meta file ", ex); return false; } } LOG.info("Using segment configuration: " + segmentConf); // init indexes for (Triple.COLLATION order : orders) { try { File indexRoot = new File(rootDir.getAbsolutePath() + File.separator + order); Index index; if (indexRoot.isDirectory()) { LOG.info("Opening index " + order); index = Index.openIndex(indexRoot, order, this); } else { LOG.info("Creating index " + order); index = Index.createIndex(indexRoot, order, this); if (router.getLocalPeer() == router.locateSegment(order, SegmentInfo.getSeed(0))) { index.createSeedSegment(); } } indexes.put(order, index); router.initialize(order); } catch (IOException ex) { LOG.fatal("error while opening index " + order, ex); return false; } } router.syncLocalCatalog(); // create segment descriptors for (Index index : indexes.values()) { for (SegmentInfo info : router.getLocalCatalog().getSegments(index.getOrder())) { segments.put(Long.valueOf(info.getSegmentId()), new SegmentDescriptor(SegmentStatus.OFFLINE, info, index)); } } LOG.info("Segment catalog initialized: " + router.getLocalCatalog()); return true; }