private String createSession() { final ImmutableSession session = ImmutableSession.builder() .name(name) .ttl(Optional.fromNullable(ttl)) .build(); return consul.sessionClient().createSession(session).getId(); }
ttl(ttlOptional);
@Override protected void doStart() throws Exception { if (sessionId.get() == null) { client = configuration.createConsulClient(getCamelContext()); sessionClient = client.sessionClient(); keyValueClient = client.keyValueClient(); sessionId.set( sessionClient.createSession( ImmutableSession.builder() .name(getNamespace()) .ttl(configuration.getSessionTtl() + "s") .lockDelay(configuration.getSessionLockDelay() + "s") .build() ).getId() ); LOGGER.debug("Acquired session with id '{}'", sessionId.get()); boolean lock = acquireLock(); LOGGER.debug("Acquire lock on path '{}' with id '{}' result '{}'", path, sessionId.get(), lock); localMember.setMaster(lock); watcher.watch(); } }
ImmutableSession.builder() .name(serviceName) .ttl(ttl + "s") .lockDelay(lockDelay + "s") .build()
/** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the <em>Jackson</em>-binding infrastructure */ @Deprecated @JsonCreator static ImmutableSession fromJson(Json json) { ImmutableSession.Builder builder = ImmutableSession.builder(); if (json.lockDelay != null) { builder.lockDelay(json.lockDelay); } if (json.name != null) { builder.name(json.name); } if (json.node != null) { builder.node(json.node); } if (json.checks != null) { builder.addAllChecks(json.checks); } if (json.behavior != null) { builder.behavior(json.behavior); } if (json.ttl != null) { builder.ttl(json.ttl); } return builder.build(); }