Search in sources :

Example 6 with ConfigDatabase

use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.

the class ConfigOpTest method testGetDefaultWithNoLocalRepository.

@Test
public void testGetDefaultWithNoLocalRepository() {
    ConfigDatabase database = mock(ConfigDatabase.class);
    when(database.get(anyString())).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
    when(database.getGlobal(anyString())).thenReturn(Optional.of("value"));
    ConfigOp config = new ConfigOp(database);
    config.setScope(ConfigScope.DEFAULT).setAction(ConfigAction.CONFIG_GET).setName("section.key").setValue(null).call();
}
Also used : ConfigOp(org.locationtech.geogig.api.porcelain.ConfigOp) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) ConfigException(org.locationtech.geogig.api.porcelain.ConfigException) Test(org.junit.Test)

Example 7 with ConfigDatabase

use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.

the class ConfigOpTest method testListDefaultWithNoLocalRepository.

@Test
public void testListDefaultWithNoLocalRepository() {
    ConfigDatabase database = mock(ConfigDatabase.class);
    when(database.getAll()).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
    ConfigOp config = new ConfigOp(database);
    config.setScope(ConfigScope.DEFAULT).setAction(ConfigAction.CONFIG_LIST).setName(null).setValue(null).call();
}
Also used : ConfigOp(org.locationtech.geogig.api.porcelain.ConfigOp) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) ConfigException(org.locationtech.geogig.api.porcelain.ConfigException) Test(org.junit.Test)

Example 8 with ConfigDatabase

use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.

the class ConfigOpTest method testListLocalWithNoLocalRepository.

@Test
public void testListLocalWithNoLocalRepository() {
    ConfigDatabase database = mock(ConfigDatabase.class);
    when(database.getAll()).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
    ConfigOp config = new ConfigOp(database);
    exception.expect(ConfigException.class);
    config.setScope(ConfigScope.LOCAL).setAction(ConfigAction.CONFIG_LIST).setName(null).setValue(null).call();
}
Also used : ConfigOp(org.locationtech.geogig.api.porcelain.ConfigOp) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) ConfigException(org.locationtech.geogig.api.porcelain.ConfigException) Test(org.junit.Test)

Example 9 with ConfigDatabase

use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.

the class ConfigOpTest method testGetLocalWithNoLocalRepository.

@Test
public void testGetLocalWithNoLocalRepository() {
    ConfigDatabase database = mock(ConfigDatabase.class);
    when(database.get(anyString())).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
    ConfigOp config = new ConfigOp(database);
    exception.expect(ConfigException.class);
    config.setScope(ConfigScope.LOCAL).setAction(ConfigAction.CONFIG_GET).setName("section.key").setValue(null).call();
}
Also used : ConfigOp(org.locationtech.geogig.api.porcelain.ConfigOp) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) ConfigException(org.locationtech.geogig.api.porcelain.ConfigException) Test(org.junit.Test)

Example 10 with ConfigDatabase

use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.

the class MeteredCommandHook method pre.

@Override
public <C extends AbstractGeoGigOp<?>> C pre(C command) throws CannotRunGeogigOperationException {
    Boolean enabled;
    if (command.context().repository() == null) {
        return command;
    }
    ConfigDatabase configDb = command.context().configDatabase();
    try {
        enabled = configDb.get(METRICS_ENABLED, Boolean.class).or(Boolean.FALSE);
    } catch (ConfigException e) {
        if (StatusCode.INVALID_LOCATION.equals(e.statusCode)) {
            enabled = Boolean.FALSE;
        } else {
            throw e;
        }
    }
    if (!enabled.booleanValue()) {
        return command;
    }
    final Platform platform = command.context().platform();
    final long startTime = platform.currentTimeMillis();
    final long nanoTime = platform.nanoTime();
    final String name = command.getClass().getSimpleName();
    CallStack stack = CallStack.push(name, startTime, nanoTime);
    command.getClientData().put("metrics.callStack", stack);
    return command;
}
Also used : Platform(org.locationtech.geogig.api.Platform) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) ConfigException(org.locationtech.geogig.api.porcelain.ConfigException)

Aggregations

ConfigDatabase (org.locationtech.geogig.storage.ConfigDatabase)18 File (java.io.File)6 ConfigException (org.locationtech.geogig.api.porcelain.ConfigException)6 IniFileConfigDatabase (org.locationtech.geogig.storage.fs.IniFileConfigDatabase)6 Test (org.junit.Test)4 Remote (org.locationtech.geogig.api.Remote)4 ConfigOp (org.locationtech.geogig.api.porcelain.ConfigOp)4 Hints (org.locationtech.geogig.repository.Hints)4 Platform (org.locationtech.geogig.api.Platform)3 Cache (com.google.common.cache.Cache)1 AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 DB (com.mongodb.DB)1 MongoClient (com.mongodb.MongoClient)1 MongoClientURI (com.mongodb.MongoClientURI)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1