clebertsuconic commented on code in PR #6191: URL: https://github.com/apache/artemis/pull/6191#discussion_r2729091056
########## artemis-lockmanager/artemis-lockmanager-etcd/src/main/java/org/apache/activemq/artemis/lockmanager/etcd/EtcdDistributedLockManagerFactory.java: ########## @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.activemq.artemis.lockmanager.etcd; + +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.apache.activemq.artemis.lockmanager.DistributedLockManager; +import org.apache.activemq.artemis.lockmanager.DistributedLockManagerFactory; + +public class EtcdDistributedLockManagerFactory implements DistributedLockManagerFactory { + + @Override + public DistributedLockManager build(Map<String, String> config) { + + EtcdLockConfiguration lockConfiguration = new EtcdLockConfiguration() + .setUser(config.getOrDefault(USER, DEFAULT_USER)) + .setPassword(config.getOrDefault(PASSWORD, DEFAULT_PASSWORD)) + .setAuthority(config.getOrDefault(AUTHORITY, DEFAULT_AUTHORITY)) + .setLeasePeriod(Integer.parseInt(config.getOrDefault(LEASE_PERIOD, DEFAULT_LEASE_PERIOD))) + .setEndpoints(config.get(CONNECT_STRING)); + + return new EtcdDistributedLockManager(lockConfiguration); + } + + @Override + public String getName() { + return "etcd"; + } + + @Override + public String getImplName() { + return EtcdDistributedLockManager.class.getName(); + } + + public static String CONNECT_STRING = "connect-string"; + public static String USER = "user"; + public static String DEFAULT_USER = null; + public static String PASSWORD = "password"; + public static String DEFAULT_PASSWORD = null; + public static String AUTHORITY = "authority"; + public static String DEFAULT_AUTHORITY = null; + public static String LEASE_PERIOD = "lease-period"; + public static String DEFAULT_LEASE_PERIOD = "10"; + + public static final Set<String> VALID_PARAMS = Stream.of( + USER, PASSWORD, AUTHORITY, LEASE_PERIOD).collect(Collectors.toSet()); Review Comment: thank you. I moved / copied from code Franz had on the LockManager, but I agree with you. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
