/** * Handles the given raw data for a regular record. * * @param buffer * Byte buffer containing the raw data for the record */ protected void handleRegularRecord(final ByteBuffer buffer) { this.regularRecordHandler.enqueueRegularRecord(buffer); }
@Override public void run() { while (true) { try { final ByteBuffer nextRecord = this.queue.take(); this.readRegularRecord(nextRecord); } catch (final InterruptedException e) { LOGGER.error("Regular record handler was interrupted", e); } } }
private void readRegularRecord(final ByteBuffer buffer) { final long registryId = buffer.getLong(); final int classId = buffer.getInt(); final long loggingTimestamp = buffer.getLong(); final ReaderRegistry<String> stringRegistry = this.getStringRegistry(registryId); try { final String recordClassName = stringRegistry.get(classId); final IRecordFactory<? extends IMonitoringRecord> recordFactory = this.cachedRecordFactoryCatalog.get(recordClassName); final IMonitoringRecord record = recordFactory.create(BinaryValueDeserializer.create(buffer, stringRegistry)); record.setLoggingTimestamp(loggingTimestamp); this.reader.deliverRecord(record); } catch (final RecordInstantiationException e) { LOGGER.error("Error instantiating record", e); } }
@Override public boolean init() { final boolean superInitSucceeded = super.init(); if (!superInitSucceeded) { return false; } // Set up record handlers this.registryRecordHandler = new RegistryRecordHandler(this.stringRegistryLookup); this.regularRecordHandler = new RegularRecordHandler(this, this.stringRegistryLookup); // Set up threads this.registryRecordHandlerThread = new Thread(this.registryRecordHandler); this.registryRecordHandlerThread.setDaemon(true); this.regularRecordHandlerThread = new Thread(this.regularRecordHandler); this.regularRecordHandlerThread.setDaemon(true); return true; }
private void readRegularRecord(final ByteBuffer buffer) { final long registryId = buffer.getLong(); final int classId = buffer.getInt(); final long loggingTimestamp = buffer.getLong(); final ILookup<String> stringRegistry = this.getStringRegistry(registryId); try { final String recordClassName = stringRegistry.get(classId); final IRecordFactory<? extends IMonitoringRecord> recordFactory = this.cachedRecordFactoryCatalog.get(recordClassName); final IMonitoringRecord record = recordFactory.create(DefaultValueDeserializer.create(buffer, stringRegistry)); record.setLoggingTimestamp(loggingTimestamp); this.reader.deliverRecord(record); } catch (final RecordInstantiationException e) { LOG.error("Error instantiating record", e); } }
@Override public boolean init() { final boolean superInitSucceeded = super.init(); if (!superInitSucceeded) { return false; } // Set up record handlers this.registryRecordHandler = new RegistryRecordHandler(this.stringRegistryLookup); this.regularRecordHandler = new RegularRecordHandler(this, this.stringRegistryLookup); // Set up threads this.registryRecordHandlerThread = new Thread(this.registryRecordHandler); this.registryRecordHandlerThread.setDaemon(true); this.regularRecordHandlerThread = new Thread(this.regularRecordHandler); this.regularRecordHandlerThread.setDaemon(true); return true; }
/** * Handles the given raw data for a regular record. * * @param buffer * Byte buffer containing the raw data for the record */ protected void handleRegularRecord(final ByteBuffer buffer) { this.regularRecordHandler.enqueueRegularRecord(buffer); }
@Override public void run() { while (true) { try { final ByteBuffer nextRecord = this.queue.take(); this.readRegularRecord(nextRecord); } catch (final InterruptedException e) { LOG.error("Regular record handler was interrupted", e); } } }