Skip to content

Commit

Permalink
Split store options b/w single&distributed
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Bottard committed Mar 11, 2014
1 parent 4517941 commit 7ad9322
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
Expand Up @@ -13,7 +13,6 @@

package org.springframework.xd.dirt.server;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
Expand All @@ -37,9 +36,6 @@ public class SingleNodeApplication {

private ConfigurableApplicationContext containerContext;

@Value("${XD_CONTROL_TRANSPORT}")
private String controlTransport;

public static final String SINGLE_PROFILE = "single";

public static void main(String[] args) {
Expand All @@ -55,8 +51,7 @@ public SingleNodeApplication run(String... args) {
new SingleNodeOptions());

SpringApplicationBuilder admin =
new SpringApplicationBuilder(SingleNodeOptions.class, ParentConfiguration.class,
SingleNodeApplication.class)
new SpringApplicationBuilder(SingleNodeOptions.class, ParentConfiguration.class)
.listeners(commandLineListener)
.profiles(AdminServerApplication.ADMIN_PROFILE, SINGLE_PROFILE)
.child(SingleNodeOptions.class, AdminServerApplication.class)
Expand All @@ -73,6 +68,8 @@ public SingleNodeApplication run(String... args) {
adminContext = admin.context();
containerContext = container.context();

String controlTransport = adminContext.getEnvironment().getProperty(
"XD_CONTROL_TRANSPORT");
if (FromResourceLocationOptionHandlers.SINGLE_NODE_SPECIAL_CONTROL_TRANSPORT.equals(controlTransport)) {
setUpControlChannels(adminContext, containerContext);
}
Expand Down
Expand Up @@ -21,7 +21,7 @@
import org.kohsuke.args4j.Option;

import org.springframework.xd.dirt.server.options.FromResourceLocationOptionHandlers.DistributedAnalyticsOptionHandler;
import org.springframework.xd.dirt.server.options.FromResourceLocationOptionHandlers.StoreOptionHandler;
import org.springframework.xd.dirt.server.options.FromResourceLocationOptionHandlers.DistributedStoreOptionHandler;


/**
Expand All @@ -36,9 +36,10 @@ public class CommonDistributedOptions extends CommonOptions {
usage = "How to persist analytics such as counters and gauges")
private String analytics;

// Should be pushed down to AdminOptions but currently
// can't b/c of the way container runtime info is persisted
@Option(name = "--store", handler = StoreOptionHandler.class,
// Should be pushed down to AdminOptions (and would then be able to include memory)
// but currently can't b/c of the way container runtime info is persisted.
// Likely to change with ZK support anyway.
@Option(name = "--store", handler = DistributedStoreOptionHandler.class,
usage = "How to persist admin data")
private String store;

Expand Down
Expand Up @@ -120,13 +120,24 @@ public DistributedAnalyticsOptionHandler(CmdLineParser parser, OptionDef option,
/**
* Computes values for --store in the distributed case (memory is NOT supported).
*/
public static class StoreOptionHandler extends FromResourceLocationOptionHandler {
public static class DistributedStoreOptionHandler extends FromResourceLocationOptionHandler {

public StoreOptionHandler(CmdLineParser parser, OptionDef option, Setter<String> setter)
public DistributedStoreOptionHandler(CmdLineParser parser, OptionDef option, Setter<String> setter)
throws IOException {
super(parser, option, setter, CONFIGURATION_ROOT + "store/*-store.xml");
exclude("memory");
}
}

/**
* Computes values for --store in the singlenode case.
*/
public static class SingleNodeStoreOptionHandler extends FromResourceLocationOptionHandler {

public SingleNodeStoreOptionHandler(CmdLineParser parser, OptionDef option, Setter<String> setter)
throws IOException {
super(parser, option, setter, CONFIGURATION_ROOT + "store/*-store.xml");
}
}


Expand Down
Expand Up @@ -24,7 +24,7 @@
import org.springframework.xd.dirt.server.options.FromResourceLocationOptionHandlers.SingleNodeAnalyticsOptionHandler;
import org.springframework.xd.dirt.server.options.FromResourceLocationOptionHandlers.SingleNodeControlTransportOptionHandler;
import org.springframework.xd.dirt.server.options.FromResourceLocationOptionHandlers.SingleNodeDataTransportOptionHandler;
import org.springframework.xd.dirt.server.options.FromResourceLocationOptionHandlers.StoreOptionHandler;
import org.springframework.xd.dirt.server.options.FromResourceLocationOptionHandlers.SingleNodeStoreOptionHandler;


/**
Expand All @@ -50,7 +50,7 @@ public class SingleNodeOptions extends CommonOptions {
usage = "The transport to use for control messages (between admin and nodes)")
private String controlTransport;

@Option(name = "--store", handler = StoreOptionHandler.class,
@Option(name = "--store", handler = SingleNodeStoreOptionHandler.class,
usage = "How to persist admin data")
private String store;

Expand Down

0 comments on commit 7ad9322

Please sign in to comment.