@Override public int available() throws IOException { return in.available(); }
@Override public int available() throws IOException { return in.available(); }
private void readData(Input i, Kryo kryo, long fromTime, long toTime, final boolean reverse) { monitoringDataList = new ArrayList<MonitoringData>(); try { while (i.available() > 0) { try { Object data = kryo.readClassAndObject(i); if (data instanceof MonitoringData){ MonitoringData monitoringData = (MonitoringData) data; if (monitoringData.getTimeStamp().getTime() <= toTime && monitoringData.getTimeStamp().getTime() >= fromTime) { monitoringDataList.add(monitoringData); } } } catch (KryoException e){ logger.error("cant load old monitoringdata: "+e.getMessage()+" , skip file:"+file.getAbsolutePath()); break; } } } catch (IOException e) { throw new RuntimeException(e); } Collections.sort(monitoringDataList, new Comparator<MonitoringData>() { @Override public int compare(MonitoringData o1, MonitoringData o2) { return o1.getTimeStamp().compareTo(o2.getTimeStamp()); } }); if (!reverse) Collections.reverse(monitoringDataList); }
@Override public Slice deserialize(Input input) { if (input.getInputStream() != null) { // The input is backed by a stream, cannot directly use its internal buffer try { return new Slice(input.readBytes(input.available())); } catch (IOException ex) { throw Throwables.propagate(ex); } } else { return new Slice(input.getBuffer(), input.position(), input.limit() - input.position()); } } }
public long readBinaryDump(Input input, BatchTransaction tx, NodeCache<Long, Long> cache) throws IOException { if (input.available() > 0) { KryoSerializationTypes type = KryoSerializationTypes.valueOf(kryo.readObject(input, String.class));