GatewayReceiverStats extends CacheServerStats { public static GatewayReceiverStats createGatewayReceiverStats(StatisticsFactory f, String ownerName, MeterRegistry meterRegistry) { StatisticDescriptor[] descriptors = new StatisticDescriptor[] { f.createIntCounter(DUPLICATE_BATCHES_RECEIVED, "number of batches which have already been seen by this GatewayReceiver", "nanoseconds"), f.createIntCounter(OUT_OF_ORDER_BATCHES_RECEIVED, "number of batches which are out of order on this GatewayReceiver", "operations"), f.createIntCounter(EARLY_ACKS, "number of early acknowledgements sent to gatewaySenders", "operations"), f.createLongCounter(EVENTS_RECEIVED, EVENTS_RECEIVED_COUNTER_DESCRIPTION, EVENTS_RECEIVED_COUNTER_UNITS), f.createIntCounter(CREAT_REQUESTS, "total number of create operations received by this GatewayReceiver", "operations"), f.createIntCounter(UPDATE_REQUESTS, "total number of update operations received by this GatewayReceiver", "operations"), f.createIntCounter(DESTROY_REQUESTS, "total number of destroy operations received by this GatewayReceiver", "operations"), f.createIntCounter(UNKNOWN_OPERATIONS_RECEIVED, "total number of unknown operations received by this GatewayReceiver", "operations"), f.createIntCounter(EXCEPTIONS_OCCURRED, "number of exceptions occurred while porcessing the batches", "operations"), f.createIntCounter(EVENTS_RETRIED, "total number events retried by this GatewayReceiver due to exceptions", "operations")}; return new GatewayReceiverStats(f, ownerName, typeName, descriptors, meterRegistry); } GatewayReceiverStats(StatisticsFactory f, String ownerName, String typeName,
      StatisticDescriptor[] descriptiors, MeterRegistry meterRegistry); static GatewayReceiverStats createGatewayReceiverStats(StatisticsFactory f,
      String ownerName, MeterRegistry meterRegistry); void incDuplicateBatchesReceived(); int getDuplicateBatchesReceived(); void incOutoforderBatchesReceived(); int getOutoforderBatchesReceived(); void incEarlyAcks(); int getEarlyAcks(); void incEventsReceived(int delta); int getEventsReceived(); void incCreateRequest(); int getCreateRequest(); void incUpdateRequest(); int getUpdateRequest(); void incDestroyRequest(); int getDestroyRequest(); void incUnknowsOperationsReceived(); int getUnknowsOperationsReceived(); void incExceptionsOccurred(); int getExceptionsOccurred(); void incEventsRetried(); int getEventsRetried(); long startTime(); @Override void close();  }
@Test public void eventsReceivedMeter_descriptionMatchesEventsReceivedStat() { gatewayReceiverStats = createGatewayReceiverStats(factory, ownerName, registry); ArgumentCaptor<String> descriptionCaptor = ArgumentCaptor.forClass(String.class); verify(factory) .createLongCounter(eq(EVENTS_RECEIVED_STAT_NAME), descriptionCaptor.capture(), any()); assertThat(meterNamed(EVENTS_RECEIVED_COUNTER_NAME)) .as("events received counter") .isNotNull(); assertThat(meterNamed(EVENTS_RECEIVED_COUNTER_NAME).getId().getDescription()) .as("meter description") .isEqualTo(descriptionCaptor.getValue()); }
@Test public void eventsReceivedMeter_unitsMatchesEventsReceivedStat() { gatewayReceiverStats = createGatewayReceiverStats(factory, ownerName, registry); ArgumentCaptor<String> unitsCaptor = ArgumentCaptor.forClass(String.class); verify(factory).createLongCounter(eq(EVENTS_RECEIVED_STAT_NAME), any(), unitsCaptor.capture()); assertThat(meterNamed(EVENTS_RECEIVED_COUNTER_NAME)) .as("events received counter") .isNotNull(); assertThat(meterNamed(EVENTS_RECEIVED_COUNTER_NAME).getId().getBaseUnit()) .as("meter base unit") .isEqualTo(unitsCaptor.getValue()); }