@Override public void run() { KeyValueClient keyValueClient = consul.keyValueClient(); Optional<Value> optValue = keyValueClient.getValue("com/lkl/consul/kvs"); if (optValue.isPresent()) { Value value = optValue.get(); long flag = value.getFlags(); System.out.println("flag:" + flag); String propString = new String(Base64.decodeBase64(value.getValue().get())); System.out.println(propString); } } }
props.put(reqKey+".modifyIndex", String.valueOf(value.getModifyIndex())); props.put(reqKey+".lockIndex", String.valueOf(value.getLockIndex())); props.put(reqKey+".flags", String.valueOf(value.getFlags())); return new PropertyValueBuilder(key, value.getValue().get(), getName()).setContextData(props).build();
protected void onValue(Value value) { final Exchange exchange = endpoint.createExchange(); final Message message = exchange.getIn(); message.setHeader(ConsulConstants.CONSUL_KEY, value.getKey()); message.setHeader(ConsulConstants.CONSUL_RESULT, true); message.setHeader(ConsulConstants.CONSUL_FLAGS, value.getFlags()); message.setHeader(ConsulConstants.CONSUL_CREATE_INDEX, value.getCreateIndex()); message.setHeader(ConsulConstants.CONSUL_LOCK_INDEX, value.getLockIndex()); message.setHeader(ConsulConstants.CONSUL_MODIFY_INDEX, value.getModifyIndex()); if (value.getSession().isPresent()) { message.setHeader(ConsulConstants.CONSUL_SESSION, value.getSession().get()); } message.setBody(configuration.isValueAsString() ? value.getValueAsString().orElse(null) : value.getValue().orElse(null)); try { getProcessor().process(exchange); } catch (Exception e) { getExceptionHandler().handleException("Error processing exchange", exchange, e); } }
/** * Fill a builder with attribute values from the provided {@code Value} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(Value instance) { Preconditions.checkNotNull(instance, "instance"); createIndex(instance.getCreateIndex()); modifyIndex(instance.getModifyIndex()); lockIndex(instance.getLockIndex()); key(instance.getKey()); flags(instance.getFlags()); Optional<String> valueOptional = instance.getValue(); if (valueOptional.isPresent()) { value(valueOptional); } Optional<String> sessionOptional = instance.getSession(); if (sessionOptional.isPresent()) { session(sessionOptional); } return this; }