Skip to content

Commit

Permalink
0003386: Populate deployment sub type on sym_node
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpmind-josh committed Jan 19, 2018
1 parent b623c37 commit ace2868
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 13 deletions.
Expand Up @@ -53,6 +53,7 @@
import org.jumpmind.properties.TypedProperties;
import org.jumpmind.security.SecurityServiceFactory;
import org.jumpmind.security.SecurityServiceFactory.SecurityServiceType;
import org.jumpmind.symmetric.common.Constants;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.common.SystemConstants;
import org.jumpmind.symmetric.db.ISymmetricDialect;
Expand Down Expand Up @@ -122,6 +123,7 @@ public ClientSymmetricEngine(DataSource dataSource, ApplicationContext springCon
Properties properties, boolean registerEngine) {
super(registerEngine);
setDeploymentType(DEPLOYMENT_TYPE_CLIENT);
setDeploymentSubTypeByProperties(properties);
this.dataSource = dataSource;
this.springContext = springContext;
this.properties = properties;
Expand All @@ -132,6 +134,7 @@ public ClientSymmetricEngine(DataSource dataSource, Properties properties,
boolean registerEngine) {
super(registerEngine);
setDeploymentType(DEPLOYMENT_TYPE_CLIENT);
setDeploymentSubTypeByProperties(properties);
this.dataSource = dataSource;
this.properties = properties;
this.init();
Expand All @@ -140,6 +143,7 @@ public ClientSymmetricEngine(DataSource dataSource, Properties properties,
public ClientSymmetricEngine(File propertiesFile, boolean registerEngine) {
super(registerEngine);
setDeploymentType(DEPLOYMENT_TYPE_CLIENT);
setDeploymentSubTypeByProperties(properties);
this.propertiesFile = propertiesFile;
this.init();
}
Expand All @@ -151,6 +155,7 @@ public ClientSymmetricEngine(File propertiesFile) {
public ClientSymmetricEngine(File propertiesFile, ApplicationContext springContext) {
super(true);
setDeploymentType(DEPLOYMENT_TYPE_CLIENT);
setDeploymentSubTypeByProperties(properties);
this.propertiesFile = propertiesFile;
this.springContext = springContext;
this.init();
Expand All @@ -160,9 +165,17 @@ public ClientSymmetricEngine(File propertiesFile, ApplicationContext springConte
public ClientSymmetricEngine(Properties properties, boolean registerEngine) {
super(registerEngine);
setDeploymentType(DEPLOYMENT_TYPE_CLIENT);
setDeploymentSubTypeByProperties(properties);
this.properties = properties;
this.init();
}

protected void setDeploymentSubTypeByProperties(Properties properties) {
if (properties != null) {
String loadOnly = properties.getProperty(ParameterConstants.NODE_LOAD_ONLY);
setDeploymentSubType(loadOnly != null && loadOnly.equals("true") ? Constants.DEPLOYMENT_SUB_TYPE_LOAD_ONLY : null);
}
}

public ClientSymmetricEngine(Properties properties) {
this(properties, true);
Expand Down
Expand Up @@ -156,6 +156,8 @@ abstract public class AbstractSymmetricEngine implements ISymmetricEngine {

protected String deploymentType;

protected String deploymentSubType;

protected ITypedPropertiesFactory propertiesFactory;

protected IDatabasePlatform platform;
Expand Down Expand Up @@ -282,6 +284,10 @@ public void setDeploymentType(String deploymentType) {
this.deploymentType = deploymentType;
}

public void setDeploymentSubType(String deploymentSubType) {
this.deploymentSubType = deploymentSubType;
}

protected abstract SecurityServiceType getSecurityServiceType();

protected void init() {
Expand Down Expand Up @@ -729,9 +735,9 @@ public String getEngineDescription(String msg) {
}
String formattedUptime = FormatUtils.formatDurationReadable(System.currentTimeMillis() - lastRestartTime.getTime());

return String.format( "SymmetricDS Node %s\n\t nodeId=%s\n\t groupId=%s\n\t type=%s\n\t name=%s\n\t softwareVersion=%s\n\t databaseName=%s\n\t databaseVersion=%s\n\t driverName=%s\n\t driverVersion=%s\n\t uptime=%s",
return String.format( "SymmetricDS Node %s\n\t nodeId=%s\n\t groupId=%s\n\t type=%s\n\t subType=%s\n\t name=%s\n\t softwareVersion=%s\n\t databaseName=%s\n\t databaseVersion=%s\n\t driverName=%s\n\t driverVersion=%s\n\t uptime=%s",
msg, getParameterService().getExternalId(), getParameterService().getNodeGroupId(),
getDeploymentType(), getEngineName(), Version.version(), symmetricDialect.getName(),
getDeploymentType(), getDeploymentSubType(), getEngineName(), Version.version(), symmetricDialect.getName(),
symmetricDialect.getVersion(), symmetricDialect.getDriverName(),
symmetricDialect.getDriverVersion(), formattedUptime );
}
Expand Down Expand Up @@ -1114,6 +1120,10 @@ public String getDeploymentType() {
return deploymentType;
}

public String getDeploymentSubType() {
return deploymentSubType;
}

public ITransformService getTransformService() {
return this.transformService;
}
Expand Down
Expand Up @@ -280,6 +280,8 @@ public interface ISymmetricEngine {

public String getDeploymentType();

public String getDeploymentSubType();

public IConcurrentConnectionManager getConcurrentConnectionManager();

public ITransformService getTransformService();
Expand Down
Expand Up @@ -75,6 +75,8 @@ private Constants() {

public static final String DEPLOYMENT_TYPE_REST = "rest";

public static final String DEPLOYMENT_SUB_TYPE_LOAD_ONLY = "load-only";

/**
* Use this value for the router_id in {@link DataEvent} if the router is unknown.
*/
Expand Down
Expand Up @@ -27,7 +27,8 @@
import java.util.Properties;

import org.apache.commons.lang.StringUtils;
import org.jumpmind.symmetric.Version;
import org.jumpmind.symmetric.Version;
import org.jumpmind.symmetric.common.Constants;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.db.ISymmetricDialect;
import org.jumpmind.symmetric.service.IParameterService;
Expand Down Expand Up @@ -83,6 +84,8 @@ public class Node implements Serializable, Comparable<Node> {

private String deploymentType;

private String deploymentSubType;

private int[] symmetricVersionParts;

public Node() {
Expand All @@ -98,7 +101,9 @@ public Node(Properties properties) {
setNodeGroupId(properties.getProperty(ParameterConstants.NODE_GROUP_ID));
setExternalId(properties.getProperty(ParameterConstants.EXTERNAL_ID));
setSyncUrl(properties.getProperty(ParameterConstants.SYNC_URL));
setSchemaVersion(properties.getProperty(ParameterConstants.SCHEMA_VERSION));
setSchemaVersion(properties.getProperty(ParameterConstants.SCHEMA_VERSION));
String loadOnly = properties.getProperty(ParameterConstants.NODE_LOAD_ONLY);
setDeploymentSubType(loadOnly != null && loadOnly.equals("true") ? Constants.DEPLOYMENT_SUB_TYPE_LOAD_ONLY : null);
}

public Node(IParameterService parameterService, ISymmetricDialect symmetricDialect) {
Expand Down Expand Up @@ -254,8 +259,16 @@ public void setDeploymentType(String deploymentType) {
public String getDeploymentType() {
return deploymentType;
}

public boolean requires13Compatiblity() {

public String getDeploymentSubType() {
return deploymentSubType;
}

public void setDeploymentSubType(String deploymentSubType) {
this.deploymentSubType = deploymentSubType;
}

public boolean requires13Compatiblity() {
if (symmetricVersion != null) {
if (symmetricVersion.equals("development")) {
return false;
Expand Down
Expand Up @@ -287,11 +287,12 @@ public void save(Node node) {
node.isSyncEnabled() ? 1 : 0, AppUtils.getTimezoneOffset(),
node.getBatchToSendCount(), node.getBatchInErrorCount(),
node.getCreatedAtNodeId(), node.getDeploymentType(),
node.getConfigVersion(), node.getNodeId() },
node.getDeploymentSubType(), node.getConfigVersion(),
node.getNodeId() },
new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP,
Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR });
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR });

flushNodeGroupCache();
}
Expand All @@ -306,12 +307,12 @@ public boolean updateNode(Node node) {
node.getSymmetricVersion(), node.getSyncUrl(), new Date(),
node.isSyncEnabled() ? 1 : 0, AppUtils.getTimezoneOffset(),
node.getBatchToSendCount(), node.getBatchInErrorCount(),
node.getCreatedAtNodeId(), node.getDeploymentType(),
node.getCreatedAtNodeId(), node.getDeploymentType(), node.getDeploymentSubType(),
node.getConfigVersion(), node.getNodeId() },
new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP,
Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }) == 1;
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }) == 1;

return updated;
}
Expand Down Expand Up @@ -864,6 +865,7 @@ public Node mapRow(Row rs) {
node.setBatchToSendCount(rs.getInt("batch_to_send_count"));
node.setBatchInErrorCount(rs.getInt("batch_in_error_count"));
node.setDeploymentType(rs.getString("deployment_type"));
node.setDeploymentSubType(rs.getString("deployment_sub_type"));
node.setConfigVersion(rs.getString("config_version"));
return node;
}
Expand Down
Expand Up @@ -52,13 +52,13 @@ public NodeServiceSqlMap(IDatabasePlatform platform, Map<String, String> replace
putSql("insertNodeSql",
"insert into $(node) (node_group_id, external_id, database_type, database_version, schema_version, symmetric_version, sync_url," +
"heartbeat_time, sync_enabled, timezone_offset, batch_to_send_count, batch_in_error_count, created_at_node_id, " +
"deployment_type, config_version, node_id) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
"deployment_type, deployment_sub_type, config_version, node_id) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

putSql("updateNodeSql",
"update $(node) set node_group_id=?, external_id=?, database_type=?, "
+ " database_version=?, schema_version=?, symmetric_version=?, sync_url=?, heartbeat_time=?, "
+ " sync_enabled=?, timezone_offset=?, batch_to_send_count=?, batch_in_error_count=?, "
+ " created_at_node_id=?, deployment_type=?, config_version = ? where node_id = ?");
+ " created_at_node_id=?, deployment_type=?, deployment_sub_type=?, config_version = ? where node_id = ?");

putSql("findNodeSql", "where node_id = ? ");

Expand Down Expand Up @@ -152,7 +152,7 @@ public NodeServiceSqlMap(IDatabasePlatform platform, Map<String, String> replace

putSql("selectNodePrefixSql",
"select c.node_id, c.node_group_id, c.external_id, c.sync_enabled, c.sync_url, "
+ " c.schema_version, c.database_type, c.database_version, c.symmetric_version, c.created_at_node_id, c.heartbeat_time, c.timezone_offset, c.batch_to_send_count, c.batch_in_error_count, c.deployment_type, c.config_version from "
+ " c.schema_version, c.database_type, c.database_version, c.symmetric_version, c.created_at_node_id, c.heartbeat_time, c.timezone_offset, c.batch_to_send_count, c.batch_in_error_count, c.deployment_type, c.deployment_sub_type, c.config_version from "
+ " $(node) c ");

putSql("updateNodeSecuritySql",
Expand Down
Expand Up @@ -366,6 +366,7 @@ public ISymmetricEngine install(Properties passedInProperties) throws Exception
try {

String registrationUrl = properties.getProperty(ParameterConstants.REGISTRATION_URL);
boolean loadOnly = properties.is(ParameterConstants.NODE_LOAD_ONLY, false);
if (StringUtils.isNotBlank(registrationUrl)) {
Collection<ServerSymmetricEngine> all = getEngines().values();
for (ISymmetricEngine currentEngine : all) {
Expand Down

0 comments on commit ace2868

Please sign in to comment.