InstanceDomainStore(IdentifierSourceSet identifierSources, InstanceStoreFactory instanceStoreFactory) { super(identifierSources.instanceDomainSource()); this.instanceStoreFactory = instanceStoreFactory; }
InstanceStoreV1(IdentifierSourceSet identifierSources, String name, InstanceDomain instanceDomain) { super(identifierSources.instanceSource(name)); this.instanceDomain = instanceDomain; }
MetricInfoStoreV2(IdentifierSourceSet identifierSources, PcpStringStore stringStore) { super(identifierSources.metricSource()); this.stringStore = stringStore; }
if (currentDomain != null) { instanceSources.put(currentDomain, new FixedValueIdentifierSource( currentInstanceAllocations, fallbacks.instanceSource(currentDomain))); currentInstanceAllocations, fallbacks.instanceSource(currentDomain))); .instanceDomainSource());
MetricInfoStoreV1(IdentifierSourceSet identifierSources) { super(identifierSources.metricSource()); }
InstanceStoreV2(IdentifierSourceSet identifierSources, String name, InstanceDomain instanceDomain, PcpStringStore stringStore) { super(identifierSources.instanceSource(name)); this.instanceDomain = instanceDomain; this.stringStore = stringStore; }
private void assertDomainResultMatches(List<String> input) { IdentifierSourceSet sources = new StringParsingIdentifierSourceSet(input, Collections .<String> emptyList(), FALLBACK_SOURCES); assertEquals(DOMAIN_ID, sources.instanceDomainSource().calculateId(DOMAIN_NAME, Collections.<Integer> emptySet())); }
private IdentifierSource parseMetrics(Iterable<String> metricData) { final BiMap<String, Integer> allocations = HashBiMap.<String, Integer>create(); int lineNumber = 0; for (String currentLine : metricData) { lineNumber++; if (!(currentLine.trim().isEmpty() || currentLine.trim().startsWith("#"))) { parseAllocation(allocations, lineNumber, currentLine); } } return new FixedValueIdentifierSource(allocations, fallbacks.metricSource()); }
public IdentifierSource getInstanceSource(String instanceDomain) { IdentifierSource found = instanceSources.get(instanceDomain); return (found == null) ? fallbacks.instanceSource(instanceDomain) : found; } }
@Test public void nullFileShouldUseDefaultInstanceSource() { assertEquals(FIXED_FALLBACK, buildFileSet(null, null).instanceDomainSource().calculateId( INSTANCE_NAME, NO_IDS)); }
private void assertMetricResultMatches(List<String> input) { IdentifierSourceSet sources = new StringParsingIdentifierSourceSet(Collections .<String> emptyList(), input, FALLBACK_SOURCES); assertEquals(METRIC_ID, sources.metricSource().calculateId(METRIC_NAME, Collections.<Integer> emptySet())); }
private void assertInstanceResultMatches(List<String> input) { IdentifierSourceSet sources = new StringParsingIdentifierSourceSet(input, Collections .<String> emptyList(), FALLBACK_SOURCES); assertEquals(INSTANCE_ID, sources.instanceSource(DOMAIN_NAME).calculateId(INSTANCE_NAME, Collections.<Integer> emptySet())); } }
@Test public void instanceDomainValuesShouldBeParsedFromFile() { assertEquals(DOMAIN_ID, buildFileSet(tempFile(INSTANCE_FILE), null).instanceDomainSource() .calculateId(DOMAIN_NAME, NO_IDS)); }
@Test public void metricInfoStoreShouldCreateANewPcpMetricInfoV2() { IdentifierSourceSet identifierSourceSet = mock(IdentifierSourceSet.class); PcpStringStore stringStore = mock(PcpStringStore.class); PcpString pcpString = mock(PcpString.class); IdentifierSource identifierSource = mock(IdentifierSource.class); when(identifierSourceSet.metricSource()).thenReturn(identifierSource); when(identifierSource.calculateId(eq("my.metric"), ArgumentMatchers.<Integer>anySet())).thenReturn(123); when(stringStore.createPcpString("my.metric")).thenReturn(pcpString); MetricInfoStoreV2 metricInfoStoreV2 = new MetricInfoStoreV2(identifierSourceSet, stringStore); PcpMetricInfo actual = metricInfoStoreV2.byName("my.metric"); PcpMetricInfoV2 expected = new PcpMetricInfoV2("my.metric", 123, pcpString); assertReflectionEquals(expected, actual); } }
@Test public void instanceStoreShouldCreateANewInstance() { IdentifierSourceSet identifierSourceSet = mock(IdentifierSourceSet.class); IdentifierSource identifierSource = mock(IdentifierSource.class); InstanceDomain instanceDomain = mock(InstanceDomain.class); PcpStringStore stringStore = mock(PcpStringStore.class); PcpString pcpString = mock(PcpString.class); when(identifierSourceSet.instanceSource(INSTANCE_NAME)).thenReturn(identifierSource); when(identifierSource.calculateId(eq(INSTANCE_NAME), ArgumentMatchers.<Integer>anySet())).thenReturn(123); when(stringStore.createPcpString(INSTANCE_NAME)).thenReturn(pcpString); InstanceV2.InstanceStoreV2 instanceStore = new InstanceV2.InstanceStoreV2(identifierSourceSet, INSTANCE_NAME, instanceDomain, stringStore); Instance actual = instanceStore.byName(INSTANCE_NAME); InstanceV2 expected = new InstanceV2(instanceDomain, INSTANCE_NAME, 123, pcpString); assertReflectionEquals(expected, actual); }
@Test public void instanceDomainValuesShouldBeParsedFromReader() { assertEquals(DOMAIN_ID, buildReaderSet(tempReader(INSTANCE_FILE), null) .instanceDomainSource().calculateId(DOMAIN_NAME, NO_IDS)); }
@Test public void nullFileShouldUseDefaultMetricSource() { assertEquals(FIXED_FALLBACK, buildFileSet(null, null).metricSource().calculateId( METRIC_NAME, NO_IDS)); }
@Test public void instanceValuesShouldBeParsedFromReader() { assertEquals(INSTANCE_ID, buildReaderSet(tempReader(INSTANCE_FILE), null).instanceSource( DOMAIN_NAME).calculateId(INSTANCE_NAME, NO_IDS)); }
@Test public void instanceDomainValuesShouldBeParsedFromStream() { assertEquals(DOMAIN_ID, buildStreamSet(tempStream(INSTANCE_FILE), null) .instanceDomainSource().calculateId(DOMAIN_NAME, NO_IDS)); }
@Test public void metricValuesShouldBeParsedFromFile() { assertEquals(METRIC_ID, buildFileSet(null, tempFile(METRIC_FILE)).metricSource() .calculateId(METRIC_NAME, NO_IDS)); }