Skip to content

Commit

Permalink
- Added config parameter for enabling Rest Service. Rest Service will…
Browse files Browse the repository at this point in the history
… run

on port 8085 but will not be enabled by default. Set rest.enable=true to
bring up RestService.
- Bringing back HttpService on it port 8081.
- Changing the Rest Service unit tests to use port 8085
  • Loading branch information
bhasudha committed Jul 18, 2013
1 parent c16ca1f commit 90c62c9
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 46 deletions.
1 change: 1 addition & 0 deletions config/single_node_rest_server/config/server.properties
Expand Up @@ -7,6 +7,7 @@ max.threads=100

http.enable=true
socket.enable=true
rest.enable=true

# BDB
bdb.write.transactions=false
Expand Down
Expand Up @@ -62,7 +62,7 @@ public static void oneTimeSetUp() {
logger.info("********************Starting REST Server********************");

restClientConfig = new RESTClientConfig();
restClientConfig.setHttpBootstrapURL("http://localhost:8081")
restClientConfig.setHttpBootstrapURL("http://localhost:8085")
.setTimeoutMs(1500, TimeUnit.MILLISECONDS)
.setMaxR2ConnectionPoolSize(100);
clientFactory = new HttpClientFactory();
Expand Down
20 changes: 20 additions & 0 deletions src/java/voldemort/server/VoldemortConfig.java
Expand Up @@ -36,6 +36,7 @@
import voldemort.server.http.HttpService;
import voldemort.server.niosocket.NioSocketService;
import voldemort.server.protocol.admin.AsyncOperation;
import voldemort.server.rest.RestService;
import voldemort.server.scheduler.DataCleanupJob;
import voldemort.server.scheduler.slop.BlockingSlopPusherJob;
import voldemort.server.scheduler.slop.StreamingSlopPusherJob;
Expand Down Expand Up @@ -229,6 +230,7 @@ public class VoldemortConfig implements Serializable {
// Should be removed once the proxy put implementation is stable.
private boolean proxyPutsDuringRebalance;

private boolean enableRestService;
private int numRestServiceNettyBossThreads;
private int numRestServiceNettyWorkerThreads;
private int numRestServiceStorageThreads;
Expand Down Expand Up @@ -507,6 +509,7 @@ public VoldemortConfig(Props props) {
this.enableNetworkClassLoader = props.getBoolean("enable.network.classloader", false);

// TODO: REST-Server decide on the numbers
this.enableRestService = props.getBoolean("rest.enable", false);
this.numRestServiceNettyBossThreads = props.getInt("num.rest.service.netty.boss.threads", 1);
this.numRestServiceNettyWorkerThreads = props.getInt("num.rest.service.netty.worker.threads",
10);
Expand Down Expand Up @@ -2812,6 +2815,22 @@ public void setGossipInterval(int gossipIntervalMs) {
this.gossipIntervalMs = gossipIntervalMs;
}

public boolean isRestServiceEnabled() {
return enableRestService;
}

/**
* Whether or not the {@link RestService} is enabled
* <ul>
* <li>Property :"rest.enable"</li>
* <li>Default :false</li>
* </ul>
*
*/
public void setEnableRestService(boolean enableRestService) {
this.enableRestService = enableRestService;
}

public int getNumRestServiceNettyBossThreads() {
return numRestServiceNettyBossThreads;
}
Expand Down Expand Up @@ -2872,4 +2891,5 @@ public int getRestServiceStorageThreadPoolQueueSize() {
public void setRestServiceStorageThreadPoolQueueSize(int restServiceStorageThreadPoolQueueSize) {
this.restServiceStorageThreadPoolQueueSize = restServiceStorageThreadPoolQueueSize;
}

}
25 changes: 16 additions & 9 deletions src/java/voldemort/server/VoldemortServer.java
Expand Up @@ -29,6 +29,7 @@

import voldemort.VoldemortException;
import voldemort.annotations.jmx.JmxOperation;
import voldemort.client.protocol.RequestFormatType;
import voldemort.client.protocol.admin.AdminClient;
import voldemort.cluster.Cluster;
import voldemort.cluster.Node;
Expand All @@ -37,6 +38,7 @@
import voldemort.common.service.ServiceType;
import voldemort.common.service.VoldemortService;
import voldemort.server.gossip.GossipService;
import voldemort.server.http.HttpService;
import voldemort.server.jmx.JmxService;
import voldemort.server.niosocket.NioSocketService;
import voldemort.server.protocol.RequestHandlerFactory;
Expand Down Expand Up @@ -190,18 +192,23 @@ private List<VoldemortService> createServices() {

if(voldemortConfig.isHttpServerEnabled()) {
/*
* TODO REST-Server 1. Need to decide on replacing HttpService 2.
* Need to decide on the number of threads. This needs to be
* configurable
* TODO REST-Server 1. Need to decide on replacing HttpService
*/
services.add(new HttpService(this,
storageService,
storeRepository,
RequestFormatType.VOLDEMORT_V1,
voldemortConfig.getMaxThreads(),
identityNode.getHttpPort()));

}
if(voldemortConfig.isRestServiceEnabled()) {
/*
* services.add(new HttpService(this, storageService,
* storeRepository, RequestFormatType.VOLDEMORT_V1,
* voldemortConfig.getMaxThreads(), identityNode.getHttpPort()));
* TODO REST-Server 1. Need to decide on the number of threads. This
* needs to be configurable 2. Need to configure the Rest Service
* port instead of hard coding
*/
services.add(new RestService(voldemortConfig,
identityNode.getHttpPort(),
storeRepository));
services.add(new RestService(voldemortConfig, 8085, storeRepository));
}
if(voldemortConfig.isSocketServerEnabled()) {
RequestHandlerFactory socketRequestHandlerFactory = new SocketRequestHandlerFactory(storageService,
Expand Down
Expand Up @@ -44,7 +44,7 @@ public class RestServerProtocolTests {
@BeforeClass
public static void oneTimeSetUp() {
storeNameStr = "test";
urlStr = "http://localhost:8081/";
urlStr = "http://localhost:8085/";
config = VoldemortConfig.loadFromVoldemortHome("config/single_node_rest_server/");
key1 = "The longest key ";
vectorClock = new VectorClock();
Expand Down

0 comments on commit 90c62c9

Please sign in to comment.