-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [Feature]DataProxy support monitor indicator with JMX. #1796 * [Feature]DataProxy support monitor indicator with JMX. #1796 * [Feature]DataProxy support monitor indicator with JMX. #1796 * [Feature]DataProxy support monitor indicator with JMX. #1796 * fix PR reviews. * fix PR reviews. * fix checkstyle problem. * add more unit test case. * add apache licenses. * fix checkstyle problem. * fix checkstyle problem.
- Loading branch information
1 parent
20aa154
commit e117b3c
Showing
51 changed files
with
4,353 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,65 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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. | ||
--> | ||
<!-- 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. --> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.apache.inlong</groupId> | ||
<artifactId>inlong-dataproxy</artifactId> | ||
<version>0.12.0-incubating-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<name>Apache InLong - DataProxy Source</name> | ||
<artifactId>dataproxy-source</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<guava.version>19.0</guava.version> | ||
</properties> | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.apache.inlong</groupId> | ||
<artifactId>inlong-dataproxy</artifactId> | ||
<version>0.12.0-incubating-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<name>Apache InLong - DataProxy Source</name> | ||
<artifactId>dataproxy-source</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.inlong</groupId> | ||
<artifactId>tubemq-client</artifactId> | ||
<version>${project.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>${guava.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<compiler.source>1.8</compiler.source> | ||
<compiler.target>1.8</compiler.target> | ||
<junit.version>4.13</junit.version> | ||
<guava.version>19.0</guava.version> | ||
<skipTests>false</skipTests> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.inlong</groupId> | ||
<artifactId>tubemq-client</artifactId> | ||
<version>${project.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>${guava.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-module-junit4</artifactId> | ||
<version>2.0.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-api-mockito2</artifactId> | ||
<version>2.0.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
139 changes: 139 additions & 0 deletions
139
...rce/src/main/java/org/apache/inlong/dataproxy/config/holder/CacheClusterConfigHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/** | ||
* 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.inlong.dataproxy.config.holder; | ||
|
||
import static org.apache.inlong.dataproxy.config.loader.CacheClusterConfigLoader.CACHE_CLUSTER_CONFIG_TYPE; | ||
import static org.apache.inlong.dataproxy.config.loader.ConfigLoader.RELOAD_INTERVAL; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.Timer; | ||
import java.util.TimerTask; | ||
|
||
import org.apache.commons.lang.ClassUtils; | ||
import org.apache.flume.Context; | ||
import org.apache.flume.conf.Configurable; | ||
import org.apache.inlong.dataproxy.config.loader.CacheClusterConfigLoader; | ||
import org.apache.inlong.dataproxy.config.loader.ContextCacheClusterConfigLoader; | ||
import org.apache.inlong.dataproxy.config.pojo.CacheClusterConfig; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* | ||
* CacheClusterConfigHolder | ||
*/ | ||
public class CacheClusterConfigHolder implements Configurable { | ||
|
||
public static final Logger LOG = LoggerFactory.getLogger(CacheClusterConfigHolder.class); | ||
|
||
protected Context context; | ||
private long reloadInterval; | ||
private Timer reloadTimer; | ||
private CacheClusterConfigLoader loader; | ||
|
||
private List<CacheClusterConfig> configList; | ||
|
||
/** | ||
* configure | ||
* | ||
* @param context | ||
*/ | ||
@Override | ||
public void configure(Context context) { | ||
this.context = context; | ||
this.reloadInterval = context.getLong(RELOAD_INTERVAL, 60000L); | ||
String loaderType = context.getString(CACHE_CLUSTER_CONFIG_TYPE, | ||
ContextCacheClusterConfigLoader.class.getName()); | ||
try { | ||
Class<?> loaderClass = ClassUtils.getClass(loaderType); | ||
Object loaderObject = loaderClass.getDeclaredConstructor().newInstance(); | ||
if (loaderObject instanceof CacheClusterConfigLoader) { | ||
this.loader = (CacheClusterConfigLoader) loaderObject; | ||
} | ||
} catch (Throwable t) { | ||
LOG.error("Fail to init loader,loaderType:{},error:{}", loaderType, t.getMessage()); | ||
LOG.error(t.getMessage(), t); | ||
} | ||
if (this.loader == null) { | ||
this.loader = new ContextCacheClusterConfigLoader(); | ||
} | ||
this.loader.configure(context); | ||
} | ||
|
||
/** | ||
* start | ||
*/ | ||
public void start() { | ||
try { | ||
this.reload(); | ||
this.setReloadTimer(); | ||
} catch (Exception e) { | ||
LOG.error(e.getMessage(), e); | ||
} | ||
} | ||
|
||
/** | ||
* close | ||
*/ | ||
public void close() { | ||
try { | ||
this.reloadTimer.cancel(); | ||
} catch (Exception e) { | ||
LOG.error(e.getMessage(), e); | ||
} | ||
} | ||
|
||
/** | ||
* setReloadTimer | ||
*/ | ||
private void setReloadTimer() { | ||
reloadTimer = new Timer(true); | ||
TimerTask task = new TimerTask() { | ||
|
||
/** | ||
* run | ||
*/ | ||
public void run() { | ||
reload(); | ||
} | ||
}; | ||
reloadTimer.schedule(task, new Date(System.currentTimeMillis() + reloadInterval), reloadInterval); | ||
} | ||
|
||
/** | ||
* reload | ||
*/ | ||
public void reload() { | ||
try { | ||
this.configList = this.loader.load(); | ||
} catch (Throwable e) { | ||
LOG.error(e.getMessage(), e); | ||
} | ||
} | ||
|
||
/** | ||
* get configList | ||
* | ||
* @return the configList | ||
*/ | ||
public List<CacheClusterConfig> getConfigList() { | ||
return configList; | ||
} | ||
|
||
} |
Oops, something went wrong.