Skip to content

Commit

Permalink
Added fake datastore and service key store so kairos can run in pure …
Browse files Browse the repository at this point in the history
…remote mode.
  • Loading branch information
brianhks committed Mar 19, 2019
1 parent c6ff44f commit d58e025
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ saw.setProperty(Tablesaw.PROP_MULTI_THREAD_OUTPUT, Tablesaw.PROP_VALUE_ON)

programName = "kairos-remote"
//Do not use '-' in version string, it breaks rpm uninstall.
version = "1.0"
version = "1.1"
release = saw.getProperty("KAIROS_RELEASE_NUMBER", "1") //package release number
summary = "KairosDB Remote"
description = """\
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.kairosdb</groupId>
<artifactId>kairos-remote</artifactId>
<version>1.0</version>
<version>1.1</version>
<packaging>jar</packaging>

<name>kairos-remote</name>
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/org/kairosdb/plugin/remote/FakeDatastore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.kairosdb.plugin.remote;

import org.kairosdb.core.datastore.Datastore;
import org.kairosdb.core.datastore.DatastoreMetricQuery;
import org.kairosdb.core.datastore.QueryCallback;
import org.kairosdb.core.datastore.TagSet;
import org.kairosdb.core.datastore.TagSetImpl;
import org.kairosdb.core.exception.DatastoreException;

import java.util.Collections;

public class FakeDatastore implements Datastore
{
@Override
public void close() throws InterruptedException, DatastoreException
{

}

@Override
public Iterable<String> getMetricNames(String prefix) throws DatastoreException
{
return Collections.emptyList();
}

@Override
public Iterable<String> getTagNames() throws DatastoreException
{
return Collections.emptyList();
}

@Override
public Iterable<String> getTagValues() throws DatastoreException
{
return Collections.emptyList();
}

@Override
public void queryDatabase(DatastoreMetricQuery query, QueryCallback queryCallback) throws DatastoreException
{

}

@Override
public void deleteDataPoints(DatastoreMetricQuery deleteQuery) throws DatastoreException
{

}

@Override
public TagSet queryMetricTags(DatastoreMetricQuery query) throws DatastoreException
{
return new TagSetImpl();
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/kairosdb/plugin/remote/FakeDatastoreModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.kairosdb.plugin.remote;

import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
import org.kairosdb.core.datastore.Datastore;
import org.kairosdb.core.datastore.ServiceKeyStore;

public class FakeDatastoreModule extends AbstractModule

{
@Override
protected void configure()
{
bind(Datastore.class).to(FakeDatastore.class).in(Scopes.SINGLETON);
bind(ServiceKeyStore.class).to(FakeServiceKeyStore.class).in(Scopes.SINGLETON);
}
}
45 changes: 45 additions & 0 deletions src/main/java/org/kairosdb/plugin/remote/FakeServiceKeyStore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.kairosdb.plugin.remote;

import org.kairosdb.core.datastore.ServiceKeyStore;
import org.kairosdb.core.exception.DatastoreException;

import java.util.Collections;

public class FakeServiceKeyStore implements ServiceKeyStore
{
@Override
public void setValue(String service, String serviceKey, String key, String value) throws DatastoreException
{

}

@Override
public String getValue(String service, String serviceKey, String key) throws DatastoreException
{
return null;
}

@Override
public Iterable<String> listServiceKeys(String service) throws DatastoreException
{
return Collections.emptyList();
}

@Override
public Iterable<String> listKeys(String service, String serviceKey) throws DatastoreException
{
return Collections.emptyList();
}

@Override
public Iterable<String> listKeys(String service, String serviceKey, String keyStartsWith) throws DatastoreException
{
return Collections.emptyList();
}

@Override
public void deleteKey(String service, String serviceKey, String key) throws DatastoreException
{

}
}
3 changes: 3 additions & 0 deletions src/main/resources/kairos-remote.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# Sample use case is to run clusters in parallel before migrating to larger cluster
#kairosdb.service.remote=org.kairosdb.plugin.remote.ListenerModule

# If you want kairos to run without any local datastore you can uncomment this line
#kairosdb.service.datastore=org.kairosdb.plugin.remote.FakeDatastoreModule

# Location to store data locally before it is sent off
kairosdb.remote.data_dir=.
kairosdb.remote.remote_url=http://10.92.1.41:8080
Expand Down

0 comments on commit d58e025

Please sign in to comment.