-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NIFI-12149 Create nifi-redis-utils and minor improvements to util met…
…hods Signed-off-by: Joe Gresock <jgresock@gmail.com> This closes #7812.
- Loading branch information
Showing
9 changed files
with
395 additions
and
42 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
67 changes: 67 additions & 0 deletions
67
nifi-nar-bundles/nifi-redis-bundle/nifi-redis-utils/pom.xml
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,67 @@ | ||
<?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. | ||
--> | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.nifi</groupId> | ||
<artifactId>nifi-redis-bundle</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>nifi-redis-utils</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.nifi</groupId> | ||
<artifactId>nifi-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.nifi</groupId> | ||
<artifactId>nifi-redis-service-api</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.nifi</groupId> | ||
<artifactId>nifi-ssl-context-service-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-redis</artifactId> | ||
<version>${spring.data.redis.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>redis.clients</groupId> | ||
<artifactId>jedis</artifactId> | ||
<version>${jedis.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.nifi</groupId> | ||
<artifactId>nifi-utils</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
File renamed without changes.
206 changes: 206 additions & 0 deletions
206
...i-redis-bundle/nifi-redis-utils/src/main/java/org/apache/nifi/redis/util/RedisConfig.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,206 @@ | ||
/* | ||
* 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.nifi.redis.util; | ||
|
||
import org.apache.nifi.redis.RedisType; | ||
|
||
import java.time.Duration; | ||
import java.util.Objects; | ||
|
||
public class RedisConfig { | ||
|
||
private final RedisType redisMode; | ||
private final String connectionString; | ||
|
||
private String sentinelMaster; | ||
private String sentinelPassword; | ||
private String password; | ||
|
||
private int dbIndex = 0; | ||
private int timeout = 10000; | ||
private int clusterMaxRedirects = 5; | ||
|
||
private int poolMaxTotal = 8; | ||
private int poolMaxIdle = 8; | ||
private int poolMinIdle = 0; | ||
private boolean blockWhenExhausted = true; | ||
private Duration maxWaitTime = Duration.ofSeconds(10); | ||
private Duration minEvictableIdleTime = Duration.ofSeconds(60); | ||
private Duration timeBetweenEvictionRuns = Duration.ofSeconds(30); | ||
private int numTestsPerEvictionRun = -1; | ||
private boolean testOnCreate = true; | ||
private boolean testOnBorrow = true; | ||
private boolean testOnReturn = false; | ||
private boolean testWhenIdle = true; | ||
|
||
public RedisConfig(final RedisType redisMode, final String connectionString) { | ||
this.redisMode = Objects.requireNonNull(redisMode); | ||
this.connectionString = Objects.requireNonNull(connectionString); | ||
} | ||
|
||
public RedisType getRedisMode() { | ||
return redisMode; | ||
} | ||
|
||
public String getConnectionString() { | ||
return connectionString; | ||
} | ||
|
||
public String getSentinelMaster() { | ||
return sentinelMaster; | ||
} | ||
|
||
public void setSentinelMaster(String sentinelMaster) { | ||
this.sentinelMaster = sentinelMaster; | ||
} | ||
|
||
public String getSentinelPassword() { | ||
return sentinelPassword; | ||
} | ||
|
||
public void setSentinelPassword(String sentinelPassword) { | ||
this.sentinelPassword = sentinelPassword; | ||
} | ||
|
||
public int getDbIndex() { | ||
return dbIndex; | ||
} | ||
|
||
public void setDbIndex(int dbIndex) { | ||
this.dbIndex = dbIndex; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
|
||
public int getTimeout() { | ||
return timeout; | ||
} | ||
|
||
public void setTimeout(int timeout) { | ||
this.timeout = timeout; | ||
} | ||
|
||
public int getClusterMaxRedirects() { | ||
return clusterMaxRedirects; | ||
} | ||
|
||
public void setClusterMaxRedirects(int clusterMaxRedirects) { | ||
this.clusterMaxRedirects = clusterMaxRedirects; | ||
} | ||
|
||
public int getPoolMaxTotal() { | ||
return poolMaxTotal; | ||
} | ||
|
||
public void setPoolMaxTotal(int poolMaxTotal) { | ||
this.poolMaxTotal = poolMaxTotal; | ||
} | ||
|
||
public int getPoolMaxIdle() { | ||
return poolMaxIdle; | ||
} | ||
|
||
public void setPoolMaxIdle(int poolMaxIdle) { | ||
this.poolMaxIdle = poolMaxIdle; | ||
} | ||
|
||
public int getPoolMinIdle() { | ||
return poolMinIdle; | ||
} | ||
|
||
public void setPoolMinIdle(int poolMinIdle) { | ||
this.poolMinIdle = poolMinIdle; | ||
} | ||
|
||
public boolean getBlockWhenExhausted() { | ||
return blockWhenExhausted; | ||
} | ||
|
||
public void setBlockWhenExhausted(boolean blockWhenExhausted) { | ||
this.blockWhenExhausted = blockWhenExhausted; | ||
} | ||
|
||
public Duration getMaxWaitTime() { | ||
return maxWaitTime; | ||
} | ||
|
||
public void setMaxWaitTime(Duration maxWaitTime) { | ||
this.maxWaitTime = maxWaitTime; | ||
} | ||
|
||
public Duration getMinEvictableIdleTime() { | ||
return minEvictableIdleTime; | ||
} | ||
|
||
public void setMinEvictableIdleTime(Duration minEvictableIdleTime) { | ||
this.minEvictableIdleTime = minEvictableIdleTime; | ||
} | ||
|
||
public Duration getTimeBetweenEvictionRuns() { | ||
return timeBetweenEvictionRuns; | ||
} | ||
|
||
public void setTimeBetweenEvictionRuns(Duration timeBetweenEvictionRuns) { | ||
this.timeBetweenEvictionRuns = timeBetweenEvictionRuns; | ||
} | ||
|
||
public int getNumTestsPerEvictionRun() { | ||
return numTestsPerEvictionRun; | ||
} | ||
|
||
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) { | ||
this.numTestsPerEvictionRun = numTestsPerEvictionRun; | ||
} | ||
|
||
public boolean getTestOnCreate() { | ||
return testOnCreate; | ||
} | ||
|
||
public void setTestOnCreate(boolean testOnCreate) { | ||
this.testOnCreate = testOnCreate; | ||
} | ||
|
||
public boolean getTestOnBorrow() { | ||
return testOnBorrow; | ||
} | ||
|
||
public void setTestOnBorrow(boolean testOnBorrow) { | ||
this.testOnBorrow = testOnBorrow; | ||
} | ||
|
||
public boolean getTestOnReturn() { | ||
return testOnReturn; | ||
} | ||
|
||
public void setTestOnReturn(boolean testOnReturn) { | ||
this.testOnReturn = testOnReturn; | ||
} | ||
|
||
public boolean getTestWhenIdle() { | ||
return testWhenIdle; | ||
} | ||
|
||
public void setTestWhenIdle(boolean testWhenIdle) { | ||
this.testWhenIdle = testWhenIdle; | ||
} | ||
} |
Oops, something went wrong.