Search in sources :

Example 1 with CacheProperties

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);
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) HashMapCacheService(uk.gov.gchq.gaffer.cache.impl.HashMapCacheService) NamedOperation(uk.gov.gchq.gaffer.named.operation.NamedOperation) DeleteNamedOperation(uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation) Operation(uk.gov.gchq.gaffer.operation.Operation) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) Properties(java.util.Properties) CacheProperties(uk.gov.gchq.gaffer.cache.util.CacheProperties) Test(org.junit.jupiter.api.Test)

Example 2 with CacheProperties

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);
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) HashMapCacheService(uk.gov.gchq.gaffer.cache.impl.HashMapCacheService) NamedOperation(uk.gov.gchq.gaffer.named.operation.NamedOperation) DeleteNamedOperation(uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation) Operation(uk.gov.gchq.gaffer.operation.Operation) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) Properties(java.util.Properties) CacheProperties(uk.gov.gchq.gaffer.cache.util.CacheProperties) Test(org.junit.jupiter.api.Test)

Example 3 with CacheProperties

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();
}
Also used : IOException(java.io.IOException) Properties(java.util.Properties) CacheProperties(uk.gov.gchq.gaffer.cache.util.CacheProperties)

Aggregations

Properties (java.util.Properties)3 CacheProperties (uk.gov.gchq.gaffer.cache.util.CacheProperties)3 Test (org.junit.jupiter.api.Test)2 HashMapCacheService (uk.gov.gchq.gaffer.cache.impl.HashMapCacheService)2 AddNamedOperation (uk.gov.gchq.gaffer.named.operation.AddNamedOperation)2 DeleteNamedOperation (uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation)2 NamedOperation (uk.gov.gchq.gaffer.named.operation.NamedOperation)2 Operation (uk.gov.gchq.gaffer.operation.Operation)2 GetSchema (uk.gov.gchq.gaffer.store.operation.GetSchema)2 Schema (uk.gov.gchq.gaffer.store.schema.Schema)2 IOException (java.io.IOException)1