MCPcopy Index your code
hub / github.com/chain/Core / main

Method main

analytics/src/main/java/com/chain/analytics/Application.java:45–109  ·  view source on GitHub ↗
(String args[])

Source from the content-addressed store, hash-verified

43 private static final Logger logger = LogManager.getLogger();
44
45 public static void main(String args[]) {
46 final String chainUrl = System.getenv(ENV_CHAIN_URL);
47 final String chainToken = System.getenv(ENV_CHAIN_TOKEN);
48 final String databaseUrl = System.getenv(ENV_DATABASE_URL);
49
50 if (chainUrl == null || "".equals(chainUrl)) {
51 logger.fatal("missing {} environment variable", ENV_CHAIN_URL);
52 System.exit(1);
53 }
54 if (databaseUrl == null || "".equals(databaseUrl)) {
55 logger.fatal("missing {} environment variable", ENV_DATABASE_URL);
56 System.exit(1);
57 }
58
59 //
60 // Setup the importer. The majority of connectivity and
61 // configuration errors should be caught here.
62 //
63 Importer importer = null;
64 try {
65 Client.Builder clientBuilder =
66 new Client.Builder().addURL(chainUrl).setReadTimeout(120, TimeUnit.SECONDS);
67 if (chainToken != null && chainToken.length() > 0) {
68 clientBuilder.setAccessToken(chainToken);
69 }
70 final Client client = clientBuilder.build();
71
72 // Use a connection pool.
73 ComboPooledDataSource ds = new ComboPooledDataSource();
74 ds.setDriverClass("oracle.jdbc.driver.OracleDriver");
75 ds.setJdbcUrl(databaseUrl);
76 ds.setTestConnectionOnCheckout(true);
77
78 Config config = new Config();
79 config.transactionColumns.add(
80 new Config.CustomColumn(
81 "acc_id",
82 new Schema.Varchar2(64),
83 new JsonPath(Arrays.asList("reference_data", "account", "id"))));
84
85 importer = Importer.connect(client, ds, DEFAULT_FEED_ALIAS, config);
86 } catch (BadURLException ex) {
87 logger.fatal("Unable to parse the Chain Core URL provided \"{}\".", chainUrl, ex);
88 System.exit(1);
89 } catch (PropertyVetoException ex) {
90 logger.fatal("Unable to setup JDBC. Is the Oracle driver in the classpath?", ex);
91 System.exit(1);
92 } catch (HTTPException | ConnectivityException ex) {
93 logger.fatal(
94 "Unable to connect to Chain Core at the configured URL \"{}\". "
95 + "Double check that the URL is correct and reachable.",
96 chainUrl,
97 ex);
98 System.exit(1);
99 } catch (ChainException | SQLException ex) {
100 logger.fatal("Unable to initialize importer.", ex);
101 System.exit(1);
102 }

Callers

nothing calls this directly

Calls 9

connectMethod · 0.95
processMethod · 0.95
equalsMethod · 0.80
addURLMethod · 0.80
setAccessTokenMethod · 0.80
addMethod · 0.80
infoMethod · 0.80
setReadTimeoutMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected