use of uk.gov.gchq.gaffer.cache.util.CacheProperties in project Gaffer by gchq.
the class StoreTest method shouldReturnAllSupportedOperations.
@Test
public void shouldReturnAllSupportedOperations() throws Exception {
// Given
final Properties cacheProperties = new Properties();
cacheProperties.setProperty(CacheProperties.CACHE_SERVICE_CLASS, HashMapCacheService.class.getName());
CacheServiceLoader.initialise(cacheProperties);
final Schema schema = createSchemaMock();
final StoreProperties properties = mock(StoreProperties.class);
given(properties.getJobExecutorThreadCount()).willReturn(1);
given(properties.getJobTrackerEnabled()).willReturn(true);
store.initialise("graphId", schema, properties);
// When
final List<Class<? extends Operation>> supportedOperations = Lists.newArrayList(store.getSupportedOperations());
// Then
assertNotNull(supportedOperations);
final List<Class<? extends Operation>> expectedOperations = Lists.newArrayList(AddElements.class, GetElements.class, GetAdjacentIds.class, GetAllElements.class, mock(AddElements.class).getClass(), mock(GetElements.class).getClass(), mock(GetAdjacentIds.class).getClass(), // Export
ExportToSet.class, GetSetExport.class, GetExports.class, ExportToGafferResultCache.class, GetGafferResultCacheExport.class, // Jobs
GetJobDetails.class, GetAllJobDetails.class, GetJobResults.class, // Output
ToArray.class, ToEntitySeeds.class, ToList.class, ToMap.class, ToCsv.class, ToSet.class, ToStream.class, ToVertices.class, // Named Operations
NamedOperation.class, AddNamedOperation.class, GetAllNamedOperations.class, DeleteNamedOperation.class, // Named View
AddNamedView.class, GetAllNamedViews.class, DeleteNamedView.class, // ElementComparison
Max.class, Min.class, Sort.class, // Validation
ValidateOperationChain.class, // Algorithm
GetWalks.class, // OperationChain
OperationChain.class, OperationChainDAO.class, // Other
GenerateElements.class, GenerateObjects.class, Validate.class, Count.class, CountGroups.class, Limit.class, DiscardOutput.class, GetSchema.class, Map.class, If.class, GetTraits.class, While.class, Join.class, ToSingletonList.class, ForEach.class, Reduce.class, CancelScheduledJob.class, // Function
Filter.class, Transform.class, Aggregate.class, // Context variables
SetVariable.class, GetVariable.class, GetVariables.class);
expectedOperations.sort(Comparator.comparing(Class::getName));
supportedOperations.sort(Comparator.comparing(Class::getName));
assertEquals(expectedOperations, supportedOperations);
}
use of uk.gov.gchq.gaffer.cache.util.CacheProperties in project Gaffer by gchq.
the class StoreTest method shouldReturnAllSupportedOperationsWhenJobTrackerIsDisabled.
@Test
public void shouldReturnAllSupportedOperationsWhenJobTrackerIsDisabled() throws Exception {
// Given
final Properties cacheProperties = new Properties();
cacheProperties.setProperty(CacheProperties.CACHE_SERVICE_CLASS, HashMapCacheService.class.getName());
CacheServiceLoader.initialise(cacheProperties);
final Schema schema = createSchemaMock();
final StoreProperties properties = mock(StoreProperties.class);
given(properties.getJobExecutorThreadCount()).willReturn(1);
given(properties.getJobTrackerEnabled()).willReturn(false);
store.initialise("graphId", schema, properties);
// When
final List<Class<? extends Operation>> supportedOperations = Lists.newArrayList(store.getSupportedOperations());
// Then
assertNotNull(supportedOperations);
final List<Class<? extends Operation>> expectedOperations = Lists.newArrayList(AddElements.class, GetElements.class, GetAdjacentIds.class, GetAllElements.class, mock(AddElements.class).getClass(), mock(GetElements.class).getClass(), mock(GetAdjacentIds.class).getClass(), // Export
ExportToSet.class, GetSetExport.class, GetExports.class, ExportToGafferResultCache.class, GetGafferResultCacheExport.class, // Output
ToArray.class, ToEntitySeeds.class, ToList.class, ToMap.class, ToCsv.class, ToSet.class, ToStream.class, ToVertices.class, // Named Operations
NamedOperation.class, AddNamedOperation.class, GetAllNamedOperations.class, DeleteNamedOperation.class, // Named View
AddNamedView.class, GetAllNamedViews.class, DeleteNamedView.class, // ElementComparison
Max.class, Min.class, Sort.class, // Validation
ValidateOperationChain.class, // Algorithm
GetWalks.class, // OperationChain
OperationChain.class, OperationChainDAO.class, // Other
GenerateElements.class, GenerateObjects.class, Validate.class, Count.class, CountGroups.class, Limit.class, DiscardOutput.class, GetSchema.class, GetTraits.class, Map.class, If.class, While.class, Join.class, ToSingletonList.class, ForEach.class, Reduce.class, CancelScheduledJob.class, // Function
Filter.class, Transform.class, Aggregate.class, // Context variables
SetVariable.class, GetVariable.class, GetVariables.class);
expectedOperations.sort(Comparator.comparing(Class::getName));
supportedOperations.sort(Comparator.comparing(Class::getName));
assertEquals(expectedOperations, supportedOperations);
}
use of uk.gov.gchq.gaffer.cache.util.CacheProperties in project Gaffer by gchq.
the class JcsCacheService method initialise.
@Override
public void initialise(final Properties properties) {
String configFile = properties.getProperty(CacheProperties.CACHE_CONFIG_FILE);
manager = CompositeCacheManager.getUnconfiguredInstance();
if (null != configFile) {
try {
Properties cacheProperties = readProperties(configFile);
manager.configure(cacheProperties, USE_SYSTEM_PROPERTIES, FORCE_RECONFIGURATION);
return;
} catch (final IOException e) {
throw new IllegalArgumentException("Cannot create cache using config file " + configFile, e);
}
}
LOGGER.debug("No config file configured. Using default.");
manager.configure();
}
Aggregations