/** * Creates a new instance of PxAcceptor * * @param port port to listen on * @param debug */ public FleaseAcceptor( LearnEventListener evtListener, FleaseConfig localConfig, String lockfileDir, boolean ignoreLockFileForTesting) throws IOException { this.config = localConfig; cells = new HashMap<ASCIIString, FleaseAcceptorCell>(); quit = false; lockfile = lockfileDir + "/" + LOCKFILE_NAME + config.getIdentity().hashCode(); this.evtListener = evtListener; File lock = new File(lockfile); if (lock.exists() && !ignoreLockFileForTesting) { /*waitUntilTimestamp_ms = TimeSync.getLocalSystemTime()+TimeSync.getLocalRenewInterval()+ config.getRestartWait();*/ waitUntilTimestamp_ms = System.currentTimeMillis() + config.getRestartWait(); Logging.logMessage( Logging.LEVEL_INFO, Category.replication, this, "restarted after crash (lock file %s exists). acceptor will ignore all messages for %d ms (recovery period until %s)", lockfile, config.getRestartWait(), (new Date(waitUntilTimestamp_ms)).toString()); } else { waitUntilTimestamp_ms = 0; if (ignoreLockFileForTesting) lock.delete(); if (!lock.createNewFile()) throw new IOException("Lock file exists!"); } }
/** * string representation * * @return a string */ public String toString() { return "Acceptor @ " + config.getIdentity(); }