Skip to content

Commit

Permalink
0004279: move to core as non-service
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Feb 18, 2020
1 parent dbd1bbd commit c611abe
Show file tree
Hide file tree
Showing 10 changed files with 234 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@
import org.jumpmind.symmetric.job.IJobManager;
import org.jumpmind.symmetric.job.JobManager;
import org.jumpmind.symmetric.service.IExtensionService;
import org.jumpmind.symmetric.service.IModuleService;
import org.jumpmind.symmetric.service.IMonitorService;
import org.jumpmind.symmetric.service.impl.ClientExtensionService;
import org.jumpmind.symmetric.service.impl.ModuleService;
import org.jumpmind.symmetric.service.impl.MonitorService;
import org.jumpmind.symmetric.statistic.IStatisticManager;
import org.jumpmind.symmetric.statistic.StatisticManager;
Expand Down Expand Up @@ -106,8 +104,6 @@ public class ClientSymmetricEngine extends AbstractSymmetricEngine {

protected IMonitorService monitorService;

protected IModuleService moduleService;

/**
* @param dataSource
* If not null, SymmetricDS will use this provided datasource
Expand Down Expand Up @@ -208,7 +204,6 @@ protected void init() {

this.monitorService = new MonitorService(parameterService, symmetricDialect, nodeService, extensionService,
clusterService, contextService);
this.moduleService = new ModuleService(parameterService, symmetricDialect);
this.dataSource = platform.getDataSource();

PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
Expand Down Expand Up @@ -545,9 +540,4 @@ public IMonitorService getMonitorService() {
return monitorService;
}

@Override
public IModuleService getModuleService() {
return moduleService;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,13 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.JdbcDatabasePlatformFactory;
import org.jumpmind.properties.TypedProperties;
import org.jumpmind.security.ISecurityService;
import org.jumpmind.security.SecurityConstants;
import org.jumpmind.security.SecurityServiceFactory;
import org.jumpmind.security.SecurityServiceFactory.SecurityServiceType;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.db.h2.H2SymmetricDialect;
import org.jumpmind.symmetric.io.stage.StagingManager;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.TriggerHistory;
import org.jumpmind.symmetric.service.IDataExtractorService;
Expand All @@ -67,9 +62,8 @@
import org.jumpmind.symmetric.service.IPurgeService;
import org.jumpmind.symmetric.service.IRegistrationService;
import org.jumpmind.symmetric.service.ITriggerRouterService;
import org.jumpmind.symmetric.service.impl.ClientExtensionService;
import org.jumpmind.symmetric.service.impl.ExtensionService;
import org.jumpmind.symmetric.util.SymmetricUtils;
import org.jumpmind.symmetric.util.ModuleException;
import org.jumpmind.symmetric.util.ModuleManager;
import org.jumpmind.util.AppUtils;
import org.jumpmind.util.JarBuilder;

Expand Down Expand Up @@ -143,7 +137,7 @@ public class SymmetricAdmin extends AbstractCommandLauncher {

private static final String OPTION_REVERSE = "reverse";

private static final int WIDTH = 80;
private static final int WIDTH = 120;

private static final int PAD = 3;

Expand All @@ -166,17 +160,7 @@ protected boolean requiresPropertiesFile(CommandLine line) {
String[] args = line.getArgs();
if (args.length >= 1) {
String cmd = args[0];
boolean isRequired = !ArrayUtils.contains(NO_ENGINE_REQUIRED, cmd);
if (!isRequired) {
Logger.getLogger(SymmetricUtils.class).setLevel(Level.ERROR);
Logger.getLogger(AbstractSymmetricEngine.class).setLevel(Level.ERROR);
Logger.getLogger(JdbcDatabasePlatformFactory.class).setLevel(Level.ERROR);
Logger.getLogger(H2SymmetricDialect.class).setLevel(Level.ERROR);
Logger.getLogger(StagingManager.class).setLevel(Level.ERROR);
Logger.getLogger(ClientExtensionService.class).setLevel(Level.ERROR);
Logger.getLogger(ExtensionService.class).setLevel(Level.ERROR);
}
return isRequired;
return !ArrayUtils.contains(NO_ENGINE_REQUIRED, cmd);
}
return true;
}
Expand Down Expand Up @@ -711,33 +695,53 @@ private OutputStreamWriter getWriter(List<String> args) throws IOException {
private void module(CommandLine line, List<String> args) throws Exception {
final String action = popArg(args, "Action");
final String moduleArgName = "Module";

if (action.equals("install")) {
getSymmetricEngine(false).getModuleService().install(popArg(args, moduleArgName));
} else if (action.equals("remove")) {
getSymmetricEngine(false).getModuleService().remove(popArg(args, moduleArgName));
} else if (action.equals("list-files")) {
String module = popArg(args, moduleArgName);
System.out.println("Files associated with module " + module + ":");
for (String file : getSymmetricEngine(false).getModuleService().listFiles(module)) {
System.out.println(file);
}
} else if (action.equals("list")) {
System.out.println("Installed modules:");
List<String> modules = getSymmetricEngine(false).getModuleService().list();
if (modules.size() == 0) {
System.out.println("<none>");
} else {
try {
ModuleManager mgr = ModuleManager.getInstance();

if (action.equals("install")) {
mgr.install(popArg(args, moduleArgName));
} else if (action.equals("remove")) {
mgr.remove(popArg(args, moduleArgName));
} else if (action.equals("list-files")) {
String module = popArg(args, moduleArgName);
List<String> files = mgr.listFiles(module);
System.out.println("Files associated with module " + module + ":");
for (String file : files) {
System.out.println(file);
}
} else if (action.equals("list-deps")) {
String module = popArg(args, moduleArgName);
List<String> files = mgr.listDependencies(module);
System.out.println("Files associated with module " + module + ":");
for (String file : files) {
System.out.println(file);
}
} else if (action.equals("list")) {
List<String> modules = mgr.list();
System.out.println("Installed modules:");
if (modules.size() == 0) {
System.out.println("<none>");
} else {
for (String module : modules) {
System.out.println(module);
}
}
} else if (action.equals("list-all")) {
List<String> modules = mgr.listAll();
System.out.println("Available modules:");
for (String module : modules) {
System.out.println(module);
}
} else if (action.equals("upgrade")) {
System.out.println("Upgrading modules");
mgr.upgradeAll();
}
} else if (action.equals("list-all")) {
System.out.println("Available modules:");
for (String module : getSymmetricEngine(false).getModuleService().listAll()) {
System.out.println(module);
} catch (ModuleException e) {
if (!e.isLogged()) {
System.err.println("ERROR: " + e.getMessage());
}
}
System.exit(1);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ SymAdmin.Help.send-sql=Send a SQL statement to be executed on a remote node.
SymAdmin.Help.send-schema=Send a schema update for a table to be executed on a remote node. The table definition is sent in torque XML format. If the target table is missing, it is created; if it exists it will be altered, if possible, otherwise dropped and re-created. Specify which tables to send or use no arguments to mean all configured tables.
SymAdmin.Help.send-script=Send a script to a node to be run there. The script is read from the filename provided as an argument or read from standard input. Only BeanShell scripts are supported.
SymAdmin.Help.uninstall=Uninstall all SymmetricDS objects from the database, including the SYM tables, sequences, functions, stored procedures, and triggers.
SymAdmin.Help.module=Manage modules to add or remove features. Use "list" to see currently installed modules and "list-all" to see what modules are available to install.
SymAdmin.Help.module=\nManage modules to add or remove features.\n\nmodule list List modules that are currently installed\nmodule list-all List all modules available to install\nmodule list-files <module> List files for a module that is installed\nmodule list-deps <module> List dependencies for a module\nmodule install <module> Install a module\nmodule remove <module> Remove a module
SymAdmin.Option.catalog=Look for tables in catalog.
SymAdmin.Option.schema=Look for tables in schema.
SymAdmin.Option.where=Add where clause to SQL statement that selects data from table.
Expand Down
11 changes: 7 additions & 4 deletions symmetric-client/src/main/resources/symmetric-modules.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
repos=https://jcenter.bintray.com, http://maven.jumpmind.com/repo
repos=https://jcenter.bintray.com, https://repository.mulesoft.org/nexus/content/repositories/public, http://maven.jumpmind.com/repo
bigquery=com.fasterxml.jackson.core:jackson-core:2.10.2, com.google.api:api-common:1.8.1, com.google.api-client:google-api-client:1.30.4, com.google.api:gax:1.49.1, com.google.api:gax-httpjson:0.66.1, com.google.api.grpc:proto-google-common-protos:1.17.0, com.google.api.grpc:proto-google-iam-v1:0.13.0, com.google.apis:google-api-services-bigquery:v2-rev20190907-1.30.3, com.google.auth:google-auth-library-credentials:0.18.0, com.google.auth:google-auth-library-oauth2-http:0.18.0, com.google.auto.value:auto-value-annotations:1.6.6, com.google.cloud:google-cloud-bigquery:1.99.0, com.google.cloud:google-cloud-core:1.91.3, com.google.cloud:google-cloud-core-http:1.91.3, com.google.code.findbugs:jsr305:3.0.2, com.google.code.gson:gson:2.8.6, com.google.guava:guava:28.1-android, com.google.http-client:google-http-client:1.32.1, com.google.http-client:google-http-client-appengine:1.32.1, com.google.http-client:google-http-client-jackson2:1.32.1, com.google.j2objc:j2objc-annotations:1.3, com.google.oauth-client:google-oauth-client:1.30.3, io.grpc:grpc-context:1.22.1, io.opencensus:opencensus-api:0.24.0, io.opencensus:opencensus-contrib-http-util:0.24.0, javax.annotation:javax.annotation-api:1.3.2, org.apache.httpcomponents:httpclient:4.5.10, org.apache.httpcomponents:httpcore:4.4.12, org.threeten:threetenbp:1.3.3
cassandra=com.datastax.cassandra:cassandra-driver-core:3.1.4
db2=jdbc.db2:db2jcc:9.7, net.sf.jt400:jt400:9.7
Expand All @@ -8,20 +8,23 @@ firebird=org.firebirdsql.jdbc:jaybird-jdk18:3.0.8
hana=com.sap.cloud.db.jdbc:ngdbc:2.3.62
hbase=com.google.guava:guava:28.1-android, com.google.protobuf:protobuf-java:2.5.0, com.jcraft:jsch:0.1.42, commons-configuration:commons-configuration:1.6, commons-digester:commons-digester:1.8, commons-el:commons-el:1.0, commons-httpclient:commons-httpclient:3.1, commons-net:commons-net:3.1, com.yammer.metrics:metrics-core:2.2.0, io.netty:netty:3.7.0.Final, io.netty:netty-all:4.0.50.Final, org.apache.avro:avro:1.8.2, org.apache.commons:commons-compress:1.8.1, org.apache.commons:commons-math3:3.1.1, org.apache.directory.api:api-asn1-api:1.0.0-M20, org.apache.directory.api:api-util:1.0.0-M20, org.apache.directory.server:apacheds-i18n:2.0.0-M15, org.apache.directory.server:apacheds-kerberos-codec:2.0.0-M15, org.apache.hadoop:hadoop-annotations:2.5.1, org.apache.hadoop:hadoop-auth:2.5.1, org.apache.hadoop:hadoop-common:2.5.1, org.apache.hadoop:hadoop-mapreduce-client-core:2.5.1, org.apache.hadoop:hadoop-yarn-api:2.5.1, org.apache.hadoop:hadoop-yarn-common:2.5.1, org.apache.hbase:hbase-annotations:1.3.6, org.apache.hbase:hbase-client:1.3.6, org.apache.hbase:hbase-common:1.3.6, org.apache.hbase:hbase-protocol:1.3.6, org.apache.hbase.thirdparty:hbase-shaded-gson:3.0.0, org.apache.htrace:htrace-core:3.1.0-incubating, org.apache.httpcomponents:httpclient:4.5.10, org.apache.httpcomponents:httpcore:4.4.12, org.apache.phoenix:phoenix:5.0.0-HBase-2.0, org.apache.zookeeper:zookeeper:3.4.8, org.jruby.jcodings:jcodings:1.0.8, org.jruby.joni:joni:2.1.2, xmlenc:xmlenc:0.52
hsqldb=org.hsqldb:hsqldb:2.4.1
#informix=jdbc.informix:ifxjdbc:1.0, jdbc.informix:ifxlang:1.0
#interbase=jdbc.interbase:interclient:13.2.0
ignite=org.apache.ignite:ignite-core:2.7.6
informix=jdbc.informix:ifxjdbc:1.0, jdbc.informix:ifxlang:1.0
interbase=jdbc.interbase:interclient:13.2.0
kafka=org.apache.kafka:kafka-clients:1.1.0, org.lz4:lz4-java:1.4, org.xerial.snappy:snappy-java:1.1.7.1, org.apache.avro:avro:1.8.2, org.codehaus.jackson:jackson-mapper-asl:1.9.13, com.thoughtworks.paranamer:paranamer:2.7, org.xerial.snappy:snappy-java:1.1.7.1, org.apache.commons:commons-compress:1.8.1, org.tukaani:xz:1.5, io.confluent:kafka-avro-serializer:3.2.1, io.confluent:kafka-schema-registry-client:3.2.1, io.confluent:common-config:3.2.1, io.confluent:common-utils:3.2.1, com.101tec:zkclient:0.10, org.apache.zookeeper:zookeeper:3.4.8, jline:jline:0.9.94, io.netty:netty:3.7.0.Final
mariadb=org.mariadb.jdbc:mariadb-java-client:2.4.0
mongodb=org.mongodb:mongo-java-driver:2.12.3
mssql=com.microsoft.sqlserver:sqljdbc:4.1.5605
mssql=jdbc.sqlserver:sqljdbc:4.0
#mysql=mysql:mysql-connector-java:5.1.45
nuodb=jdbc.nuodb:nuodb-jdbc:3.3.1
#oracle=jdbc:ojdbc8:18.3.0.0
#postgres=org.postgresql:postgresql:42.2.8
redshift=com.amazon.redshift:redshift-jdbc42-no-awssdk:1.2.36.1060, com.amazonaws:aws-java-sdk-s3:1.11.510, com.amazonaws:aws-java-sdk-kms:1.11.510, software.amazon.ion:ion-java:1.0.2, com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.6.7, joda-time:joda-time:2.8.1, com.amazonaws:jmespath-java:1.11.510, com.amazonaws:aws-java-sdk-core:1.11.510, com.amazonaws:jmespath-java:1.11.510
snowflake=net.snowflake:snowflake-jdbc:3.6.27, com.microsoft.azure:azure-storage:8.1.0, com.microsoft.azure:azure-keyvault-core:1.0.0, com.google.guava:guava:28.1-android
sqlite=org.xerial:sqlite-jdbc:3.25.2
#sqlserver=net.sourceforge.jtds:jtds:1.3.1
sybase=jdbc.sybase:jconnect:7.7
teradata=jdbc.teradata:terajdbc4:16.20.00.10
tibero=jdbc.tibero:tibero:6
topspeed=nl.cad:tps-parse:1.0.15-SNAPSHOT, com.beust:jcommander:1.30, joda-time:joda-time:2.8.1
voltdb=org.voltdb:voltdbclient:8.4.1
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
import org.jumpmind.symmetric.service.ILoadFilterService;
import org.jumpmind.symmetric.service.IInitialLoadService;
import org.jumpmind.symmetric.service.IMailService;
import org.jumpmind.symmetric.service.IModuleService;
import org.jumpmind.symmetric.service.INodeCommunicationService;
import org.jumpmind.symmetric.service.INodeService;
import org.jumpmind.symmetric.service.IOfflinePullService;
Expand Down Expand Up @@ -1303,11 +1302,6 @@ public IUpdateService getUpdateService() {
return updateService;
}

@Override
public IModuleService getModuleService() {
return null;
}

@Override
public String getNodeId() {
return getNodeService().findIdentityNodeId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.jumpmind.symmetric.service.IInitialLoadService;
import org.jumpmind.symmetric.service.ILoadFilterService;
import org.jumpmind.symmetric.service.IMailService;
import org.jumpmind.symmetric.service.IModuleService;
import org.jumpmind.symmetric.service.IMonitorService;
import org.jumpmind.symmetric.service.INodeCommunicationService;
import org.jumpmind.symmetric.service.INodeService;
Expand Down Expand Up @@ -319,8 +318,6 @@ public interface ISymmetricEngine {

public IUpdateService getUpdateService();

public IModuleService getModuleService();

public Date getLastRestartTime();

public <T> T getDataSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import org.jumpmind.symmetric.ISymmetricEngine;
import org.jumpmind.symmetric.common.TableConstants;
import org.jumpmind.symmetric.ext.ISymmetricEngineAware;
import org.jumpmind.symmetric.util.ModuleException;
import org.jumpmind.symmetric.util.ModuleManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -27,6 +29,11 @@ public void upgrade(String databaseVersion, String softwareVersion) {
" set max_batch_size = 10000 where reload_flag = 1 and max_batch_size = 1";
engine.getSqlTemplate().update(sql);
}
try {
ModuleManager.getInstance().upgradeAll();
} catch (ModuleException e) {
throw new RuntimeException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
import java.util.ArrayList;
import java.util.List;

import org.jumpmind.symmetric.service.impl.ModuleService;

public class MavenArtifact {

public static final String REGEX_LIST = "\\s*,\\s*";

public static final String REGEX_COMPONENTS = "\\s*:\\s*";

private String groupId;

Expand All @@ -41,7 +43,7 @@ public MavenArtifact(String groupId, String artifactId, String version) {

public MavenArtifact(String dependency) {
if (dependency != null) {
String[] array = dependency.trim().split("\\s*:\\s*");
String[] array = dependency.trim().split(REGEX_COMPONENTS);
if (array.length >= 1) {
this.groupId = array[0];
}
Expand Down Expand Up @@ -103,7 +105,7 @@ public boolean equals(Object obj) {
public static List<MavenArtifact> parseCsv(String dependencies) {
List<MavenArtifact> list = new ArrayList<MavenArtifact>();
if (dependencies != null) {
for (String dependency : dependencies.split(ModuleService.REGEX_CSV)) {
for (String dependency : dependencies.split(REGEX_LIST)) {
MavenArtifact artifact = new MavenArtifact(dependency);
if (artifact != null) {
list.add(artifact);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,29 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.service;
package org.jumpmind.symmetric.util;

import java.util.List;
public class ModuleException extends Exception {

public interface IModuleService {

public boolean install(String moduleId);

public boolean remove(String moduleId);

public List<String> list();

public List<String> listFiles(String moduleId);

public List<String> listAll();
private static final long serialVersionUID = 1L;

private boolean isLogged;

public ModuleException(String message) {
super(message);
}

public ModuleException(String message, boolean isLogged) {
super(message);
this.isLogged = isLogged;
}

public ModuleException(String message, Exception e) {
super(message, e);
}

public boolean isLogged() {
return isLogged;
}

}
Loading

0 comments on commit c611abe

Please sign in to comment.