protected static final String STARS = "*****";
- protected final Cluster cluster;
+ protected static Cluster cluster;
protected static AuthzEnv env;
protected static Session session;
protected static Set<String> specialNames;
protected final Organization org;
protected String version;
-
+ protected static final Date now = new Date();
+ protected static final Date never = new Date(0);
+
protected Batch(AuthzEnv env) throws APIException, IOException, OrganizationException {
if (batchEnv != null) {
env.info().log("Redirecting to ",batchEnv,"environment");
CassAccess.CASSANDRA_CLUSTERS_PASSWORD,
VERSION,GUI_URL,MAX_EMAILS,
LOG_DIR,
- "SPECIAL_NAMES"
+ "SPECIAL_NAMES",
+ "MAIL_TEST_TO"
}) {
if ((str = env.getProperty(batchEnv+'.'+key))!=null) {
env.setProperty(key, str);
}
// Setup for Dry Run
- cluster = CassAccess.cluster(env,batchEnv);
+ if(cluster==null) {
+ cluster = CassAccess.cluster(env,batchEnv);
+ }
env.info().log("cluster name - ",cluster.getClusterName());
String dryRunStr = env.getProperty( "DRY_RUN" );
if ( dryRunStr == null || "false".equals(dryRunStr.trim()) ) {
}
protected abstract void run(AuthzTrans trans);
- protected abstract void _close(AuthzTrans trans);
+ protected void _close(AuthzTrans trans) {}
public String[] args() {
return env.get(ssargs);
public final void close(AuthzTrans trans) {
_close(trans);
- cluster.close();
+ if(session!=null) {
+ session.close();
+ session = null;
+ }
+ if(cluster!=null && !cluster.isClosed()) {
+ cluster.close();
+ }
}
public static void main(String[] args) {
}
if (batch != null) {
- batch.run(trans);
+ try {
+ batch.run(trans);
+ } catch (Exception e) {
+ if(cluster!=null && !cluster.isClosed()) {
+ cluster.close();
+ }
+ trans.error().log(e);
+ }
}
} finally {
tt.done();
}
} catch (Exception e) {
+ if(cluster!=null && !cluster.isClosed()) {
+ cluster.close();
+ }
e.printStackTrace(System.err);
- // Exceptions thrown by DB aren't stopping the whole process.
- System.exit(1);
}
}