diff --git a/org.eclipse.ecf.provider.etcd3/bnd.bnd b/org.eclipse.ecf.provider.etcd3/bnd.bnd
index d1fc306..90a06d6 100644
--- a/org.eclipse.ecf.provider.etcd3/bnd.bnd
+++ b/org.eclipse.ecf.provider.etcd3/bnd.bnd
@@ -35,7 +35,7 @@ javac.source=17
javac.target=17
package-version = 1.0.2
-Bundle-Version: 1.3.1.${tstamp}
+Bundle-Version: 1.3.2.${tstamp}
-runfw: org.apache.felix.framework;version='[7.0.5,7.0.5]'
-runee: JavaSE-17
diff --git a/org.eclipse.ecf.provider.etcd3/pom.xml b/org.eclipse.ecf.provider.etcd3/pom.xml
index 2685efc..163c2c9 100644
--- a/org.eclipse.ecf.provider.etcd3/pom.xml
+++ b/org.eclipse.ecf.provider.etcd3/pom.xml
@@ -10,7 +10,7 @@
org.eclipse.ecf.provider.etcd3
- 1.3.1
+ 1.3.2
com.google.protobuf
diff --git a/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3ConfigConnectContext.java b/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3ConfigConnectContext.java
index 644208e..27be575 100644
--- a/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3ConfigConnectContext.java
+++ b/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3ConfigConnectContext.java
@@ -18,7 +18,7 @@
public class Etcd3ConfigConnectContext implements IConnectContext {
private final Etcd3DiscoveryContainerConfig config;
-
+
public Etcd3ConfigConnectContext(Etcd3DiscoveryContainerConfig config) {
this.config = config;
}
@@ -26,7 +26,7 @@ public Etcd3ConfigConnectContext(Etcd3DiscoveryContainerConfig config) {
public Etcd3DiscoveryContainerConfig getConfig() {
return config;
}
-
+
@Override
public CallbackHandler getCallbackHandler() {
return null;
diff --git a/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3DiscoveryContainer.java b/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3DiscoveryContainer.java
index 30454f8..d465a88 100644
--- a/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3DiscoveryContainer.java
+++ b/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3DiscoveryContainer.java
@@ -73,7 +73,7 @@
public class Etcd3DiscoveryContainer extends AbstractDiscoveryContainerAdapter {
private static final Logger logger = LoggerFactory.getLogger(Etcd3DiscoveryContainer.class);
-
+
class EtcdServiceInfoKey {
private final String sessId;
private final String serviceInfoId;
@@ -299,10 +299,10 @@ public void subscribe(FlowableEmitter emitter) throws Exception {
} catch (Exception e) {
URI uri = getEtcdConfig().getTargetLocation();
- ContainerConnectException e1 = new ContainerConnectException(
- "Cannot connect to Etcd3 server "+ uri, e);
+ ContainerConnectException e1 = new ContainerConnectException("Cannot connect to Etcd3 server " + uri,
+ e);
e1.setStackTrace(e.getStackTrace());
- logEtcdError("connect","Etcd3 connection error", e);
+ logEtcdError("connect", "Etcd3 connection error", e);
throw e1;
}
@@ -373,7 +373,7 @@ private EtcdServiceInfoKey parseServiceInfoKey(String key) {
private void handlePutWatchEvent(KeyValue keyValue) {
String key = keyValue.getKey().toStringUtf8();
- debug("handlePutWatchEvent","key="+key);
+ debug("handlePutWatchEvent", "key=" + key);
EtcdServiceInfoKey siKey = parseServiceInfoKey(key);
if (siKey != null) {
if (!siKey.matchSessionId(getSessionId())) {
@@ -398,7 +398,7 @@ private void handlePutWatchEvent(KeyValue keyValue) {
private void handleDeleteWatchEvent(KeyValue keyValue) {
String key = keyValue.getKey().toStringUtf8();
- debug("handleDeleteWatchEvent","key="+key);
+ debug("handleDeleteWatchEvent", "key=" + key);
EtcdServiceInfoKey siKey = parseServiceInfoKey(key);
if (siKey != null) {
if (!siKey.matchSessionId(getSessionId())) {
@@ -471,11 +471,11 @@ private void fireServiceTypeDiscovered(IServiceTypeID serviceTypeID) {
}
private void debug(String methodName, String message) {
- logger.debug("methodName="+methodName+",msg="+message);
+ logger.debug("methodName=" + methodName + ",msg=" + message);
}
private void logEtcdError(String method, String message, Throwable e) {
- logger.error("methodName="+method+",msg="+message,e);
+ logger.error("methodName=" + method + ",msg=" + message, e);
}
public IServiceInfo getServiceInfo(IServiceID aServiceID) {
diff --git a/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3DiscoveryContainerConfig.java b/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3DiscoveryContainerConfig.java
index 59cb8cb..156ea56 100644
--- a/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3DiscoveryContainerConfig.java
+++ b/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3DiscoveryContainerConfig.java
@@ -21,7 +21,10 @@
import org.eclipse.ecf.provider.etcd3.identity.Etcd3ServiceID;
import io.grpc.Channel;
+import io.grpc.Grpc;
import io.grpc.ManagedChannelBuilder;
+import io.grpc.ChannelCredentials;
+
import org.osgi.util.tracker.ServiceTracker;
public class Etcd3DiscoveryContainerConfig extends DiscoveryContainerConfig {
@@ -70,7 +73,7 @@ public class Etcd3DiscoveryContainerConfig extends DiscoveryContainerConfig {
private String keyPrefix = ETCD_KEYPREFIX_DEFAULT;
private int keepAliveUpdateTime = ETCD_KEEPALIVE_UPDATE_TIME_DEFAULT.intValue();
private boolean usePlaintext = ETCD_USEPLAINTEXT_DEFAULT;
- private boolean retry = ETCD_RETRY_DEFAULT;
+ private ChannelCredentials channelCredentials = null;
public static class Builder {
@@ -118,8 +121,11 @@ public Builder setUsePlaintext() {
return this;
}
- public Builder setUseRetry() {
- this.config.retry = true;
+ public Builder setChannelCredentials(ChannelCredentials credentials) {
+ if (credentials != null) {
+ this.config.usePlaintext = false;
+ }
+ this.config.channelCredentials = credentials;
return this;
}
@@ -168,14 +174,14 @@ public String getSessionId() {
return sessionId;
}
- public void setTTL(long ttl) {
- this.ttl = ttl;
- }
-
public long getTTL() {
return this.ttl;
}
+ public void setTTL(long ttl) {
+ this.ttl = ttl;
+ }
+
public String getKeyPrefix() {
return this.keyPrefix;
}
@@ -184,6 +190,14 @@ public void setKeyPrefix(String keyPrefix) {
this.keyPrefix = keyPrefix;
}
+ public ChannelCredentials getChannelCredentials() {
+ return this.channelCredentials;
+ }
+
+ public boolean usePlaintext() {
+ return this.usePlaintext;
+ }
+
public String getSessionKey() {
return String.join("/", getKeyPrefix(), getSessionId());
}
@@ -196,17 +210,30 @@ public URI getTargetLocation() {
return getTargetID().getLocation();
}
+ protected ManagedChannelBuilder> createAndConfigureManagedChannelBuilder() {
+ Activator.getDefault();
+ ServiceTracker st = new ServiceTracker(
+ Activator.getContext(), ManagedChannelBuilderConfigurer.class, null);
+ st.open();
+ ManagedChannelBuilderConfigurer configurer = st.getService();
+ st.close();
+ return (configurer != null) ? configurer.createAndConfigureManagedChannelBuilder(this) : null;
+ }
+
@SuppressWarnings("rawtypes")
protected ManagedChannelBuilder createManagedChannelBuilder() {
- URI uri = getTargetLocation();
- ManagedChannelBuilder mcBuilder = ManagedChannelBuilder.forAddress(uri.getHost(), uri.getPort());
- if (this.usePlaintext) {
- mcBuilder.usePlaintext();
- }
- if (this.retry) {
- mcBuilder.enableRetry();
+ ManagedChannelBuilder mcb = createAndConfigureManagedChannelBuilder();
+ if (mcb == null) {
+ URI uri = getTargetLocation();
+ ChannelCredentials channelCreds = getChannelCredentials();
+ mcb = (channelCreds == null) ? ManagedChannelBuilder.forAddress(uri.getHost(), uri.getPort())
+ : Grpc.newChannelBuilderForAddress(uri.getHost(), uri.getPort(), channelCreds);
+ if (usePlaintext()) {
+ mcb.usePlaintext();
+ }
+ mcb.enableRetry();
}
- return mcBuilder;
+ return mcb;
}
public Channel createChannel() {
diff --git a/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3ServiceInfo.java b/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3ServiceInfo.java
index 8cbe147..d956594 100644
--- a/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3ServiceInfo.java
+++ b/org.eclipse.ecf.provider.etcd3/src/main/java/org/eclipse/ecf/provider/etcd3/container/Etcd3ServiceInfo.java
@@ -44,7 +44,7 @@ public class Etcd3ServiceInfo extends ServiceInfo {
public static final String BYTES_TYPE = "bytes"; //$NON-NLS-1$
public static final String STRING_TYPE = "string"; //$NON-NLS-1$
public static final String LIST_TYPE = "list"; //$NON-NLS-1$
- public static final String SET_TYPE = "set"; //$NON-NLS-1$
+ public static final String SET_TYPE = "set"; //$NON-NLS-1$
public static final String DOUBLE_TYPE = "double";//$NON-NLS-1$
public static final String FLOAT_TYPE = "float";//$NON-NLS-1$
public static final String CHAR_TYPE = "char";//$NON-NLS-1$
@@ -126,7 +126,7 @@ else if (LIST_TYPE.equals(type)) {
List newList = new ArrayList();
Object obj = jsonProperty.get(VALUE_KEY);
JSONArray sarr = (JSONArray) jsonProperty.get(VALUE_KEY);
- for(int j=0; j < sarr.length(); j++) {
+ for (int j = 0; j < sarr.length(); j++) {
newList.add(sarr.get(j));
}
sProps.setProperty(name, newList);
@@ -134,7 +134,7 @@ else if (LIST_TYPE.equals(type)) {
@SuppressWarnings("rawtypes")
Set s = new HashSet();
JSONArray sarr = (JSONArray) jsonProperty.get(VALUE_KEY);
- for(int j=0; j < sarr.length(); j++) {
+ for (int j = 0; j < sarr.length(); j++) {
s.add(sarr.get(j));
}
sProps.setProperty(name, s);
@@ -246,8 +246,8 @@ public String serializeToJsonString() throws JSONException {
@SuppressWarnings("rawtypes")
List l = (List) value;
JSONArray array = new JSONArray();
- for(int i=0; i < l.size(); i++) {
- array.put(i,l.get(i));
+ for (int i = 0; i < l.size(); i++) {
+ array.put(i, l.get(i));
}
value = array;
} else if (SET_TYPE.equals(type)) {
@@ -255,11 +255,11 @@ public String serializeToJsonString() throws JSONException {
Set s = (Set) value;
JSONArray array = new JSONArray();
int i = 0;
- for(Object o: s) {
- array.put(i,o);
+ for (Object o : s) {
+ array.put(i, o);
i++;
}
- value = array;
+ value = array;
} else if (CHAR_TYPE.equals(type)) {
value = Character.toString((char) value);
} else if (LONG_TYPE.equals(type)) {