Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #76

Merged
merged 4 commits into from
Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ambari/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.srotya.sidewinder</groupId>
<artifactId>sidewinder-parent</artifactId>
<version>0.0.27-SNAPSHOT</version>
<version>0.0.28-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>ambari-stack</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archiver/hdfs-archiver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.srotya.sidewinder</groupId>
<artifactId>sidewinder-archiver</artifactId>
<version>0.0.27-SNAPSHOT</version>
<version>0.0.28-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hdfs-archiver</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
import com.srotya.sidewinder.core.storage.ArchiveException;
import com.srotya.sidewinder.core.storage.Archiver;
import com.srotya.sidewinder.core.storage.DataPoint;
import com.srotya.sidewinder.core.storage.TimeSeriesBucket;
import com.srotya.sidewinder.core.storage.compression.Reader;
import com.srotya.sidewinder.core.storage.compression.byzantine.ByzantineWriter;
import com.srotya.sidewinder.core.storage.compression.Writer;
import com.srotya.sidewinder.core.storage.mem.archival.TimeSeriesArchivalObject;

/**
Expand Down Expand Up @@ -61,11 +60,11 @@ public void testHDFSArchive() throws IOException, ArchiveException {
archiver.init(conf);
long ts = System.currentTimeMillis();
//TODO fix unit tests for HDFS Archiver
TimeSeriesBucket bucket = null;
Writer bucket = null;
for (int i = 0; i < 1000; i++) {
bucket.addDataPoint(ts + i * 1000, i);
bucket.addValue(ts + i * 1000, i);
}
Reader reader = bucket.getReader(null, null);
Reader reader = bucket.getReader();
for (int i = 0; i < 1000; i++) {
DataPoint pair = reader.readPair();
assertEquals(ts + i * 1000, pair.getTimestamp());
Expand Down
2 changes: 1 addition & 1 deletion archiver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.srotya.sidewinder</groupId>
<artifactId>sidewinder-parent</artifactId>
<version>0.0.27-SNAPSHOT</version>
<version>0.0.28-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>sidewinder-archiver</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archiver/s3-archiver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.srotya.sidewinder</groupId>
<artifactId>sidewinder-archiver</artifactId>
<version>0.0.27-SNAPSHOT</version>
<version>0.0.28-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>s3-archiver</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions build/build-info.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Release Build number:309
Release Commit number:e72d92eeab84952bfaf1d5c55a4c26de7e69add8
Release Build number:326
Release Commit number:61bf02699b9f328ce1d83ada7074ee54fa7089b0
20 changes: 19 additions & 1 deletion cluster/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.srotya.sidewinder</groupId>
<artifactId>sidewinder-parent</artifactId>
<version>0.0.27-SNAPSHOT</version>
<version>0.0.28-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>sidewinder-cluster</artifactId>
Expand All @@ -19,6 +19,12 @@
<groupId>com.facebook.jcommon</groupId>
<artifactId>util</artifactId>
<version>0.1.29</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
Expand All @@ -38,6 +44,12 @@
<groupId>io.atomix</groupId>
<artifactId>atomix-all</artifactId>
<version>1.0.5</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
Expand Down Expand Up @@ -66,6 +78,12 @@
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>3.2.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,36 @@ public void run(ClusterConfiguration configuration, Environment env) throws Exce

ScheduledExecutorService bgTasks = Executors.newScheduledThreadPool(2, new BackgrounThreadFactory("bgtasks"));

StorageEngine storageEngine;

String storageEngineClass = conf.getOrDefault("storage.engine",
"com.srotya.sidewinder.core.storage.mem.MemStorageEngine");
StorageEngine storageEngine = (StorageEngine) Class.forName(storageEngineClass).newInstance();
storageEngine.configure(conf, bgTasks);
storageEngine.connect();
try {
storageEngine = (StorageEngine) Class.forName(storageEngineClass).newInstance();
storageEngine.configure(conf, bgTasks);
storageEngine.connect();
} catch (Exception e) {
throw new IOException(e);
}

ClusterConnector connector = (ClusterConnector) Class.forName(conf.getOrDefault("cluster.connector",
"com.srotya.sidewinder.cluster.connectors.ConfigConnector")).newInstance();
connector.init(conf);
ClusterConnector connector;
try {
connector = (ClusterConnector) Class.forName(
conf.getOrDefault("cluster.connector", "com.srotya.sidewinder.cluster.connectors.ConfigConnector"))
.newInstance();
connector.init(conf);
} catch (Exception e) {
throw new IOException(e);
}

RoutingEngine router = (RoutingEngine) Class.forName(conf.getOrDefault("cluster.routing.engine",
"com.srotya.sidewinder.cluster.routing.impl.MasterSlaveRoutingEngine")).newInstance();
router.init(conf, storageEngine, connector);
RoutingEngine router;
try {
router = (RoutingEngine) Class.forName(conf.getOrDefault("cluster.routing.engine",
"com.srotya.sidewinder.cluster.routing.impl.MasterSlaveRoutingEngine")).newInstance();
router.init(conf, storageEngine, connector);
} catch (Exception e) {
throw new IOException(e);
}

final Server server = ServerBuilder.forPort(port)
.decompressorRegistry(DecompressorRegistry.getDefaultInstance())
Expand All @@ -103,22 +120,22 @@ public void run() {
});

ResourceMonitor.getInstance().init(storageEngine, bgTasks);
ClusterResourceMonitor.getInstance().init(storageEngine, connector, bgTasks);
ClusterResourceMonitor.getInstance().init(storageEngine, connector, bgTasks);
env.jersey().register(new GrafanaQueryApi(storageEngine, registry));
env.jersey().register(new MeasurementOpsApi(storageEngine, registry));
env.jersey().register(new DatabaseOpsApi(storageEngine, registry));
if (connector.isBootstrap()) {
env.jersey().register(new InfluxApi(router, registry, conf));
}
env.healthChecks().register("restapi", new RestAPIHealthCheck());

if (Boolean.parseBoolean(conf.getOrDefault(ConfigConstants.AUTH_BASIC_ENABLED, ConfigConstants.FALSE))) {
AuthFilter<BasicCredentials, Principal> basicCredentialAuthFilter = new BasicCredentialAuthFilter.Builder<>()
.setAuthenticator(new BasicAuthenticator(conf.get(ConfigConstants.AUTH_BASIC_USERS)))
.setAuthorizer(new AllowAllAuthorizer()).setPrefix("Basic").buildAuthFilter();
env.jersey().register(basicCredentialAuthFilter);
}

}

private void loadConfiguration(ClusterConfiguration configuration, HashMap<String, String> conf)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright 2017 Ambud Sharma
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.srotya.sidewinder.cluster.api;

import javax.ws.rs.BadRequestException;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

import com.codahale.metrics.MetricRegistry;
import com.srotya.sidewinder.cluster.routing.RoutingEngine;
import com.srotya.sidewinder.core.rpc.Point;

@Path("/cluster/databases")
public class DatabaseOpsApi {

public static final String DB_NAME = "dbName";
private RoutingEngine engine;

public DatabaseOpsApi(RoutingEngine engine, MetricRegistry registry) {
this.engine = engine;
if (registry != null) {
// register things
}
}

@Path("/{DB_NAME}/measurements/{MEASUREMENT_NAME}")
@POST
public void createMeasurement(@PathParam("DB_NAME") String dbName,
@PathParam("MEASUREMENT_NAME") String measurementName) {
Point point = Point.newBuilder().setDbName(dbName).setMeasurementName(measurementName).build();
try {
engine.addRoutableKey(point, 3);
} catch (UnsupportedOperationException e) {
throw new BadRequestException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ public class InfluxApi {

private Meter meter;
private RoutingEngine router;
private int replicationFactor;

public InfluxApi(RoutingEngine router, MetricRegistry registry, Map<String, String> conf) {
this.router = router;
meter = registry.meter("writes");
this.replicationFactor = Integer.parseInt(conf.getOrDefault("cluster.replication.factor", "3"));
}

@POST
Expand All @@ -64,7 +62,7 @@ public void insertData(@QueryParam("db") String dbName, String payload) {
}
meter.mark(dps.size());
for (Point dp : dps) {
List<Node> nodes = router.routeData(dp, replicationFactor);
List<Node> nodes = router.routeData(dp);
for (int i = 0; i < nodes.size(); i++) {
Node node = nodes.get(i);
System.err.println(MiscUtils.pointToDataPoint(dp)+"\t"+node);
Expand Down
Loading