You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ka...@apache.org on 2017/07/03 14:41:19 UTC
[01/40] storm git commit: Add Hugo Louro to committers list
Repository: storm
Updated Branches:
refs/heads/1.1.x-branch [created] 81e9d6579
Add Hugo Louro to committers list
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/d6aac4cc
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/d6aac4cc
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/d6aac4cc
Branch: refs/heads/1.1.x-branch
Commit: d6aac4ccedfa6ea7aacb98c3eb9f962eabc8bc15
Parents: b04ff48
Author: Hugo Louro <hm...@gmail.com>
Authored: Thu Mar 23 18:49:25 2017 -0700
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:21:31 2017 +0900
----------------------------------------------------------------------
README.markdown | 1 +
pom.xml | 9 +++++++++
2 files changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/d6aac4cc/README.markdown
----------------------------------------------------------------------
diff --git a/README.markdown b/README.markdown
index a5a5e88..3d66603 100644
--- a/README.markdown
+++ b/README.markdown
@@ -93,6 +93,7 @@ under the License.
* Haohui Mai ([@haohui](https://github.com/haohui))
* Longda Feng ([@longda](https://github.com/longdafeng))
* Xin Wang ([@vesense](https://github.com/vesense))
+* Hugo da Cruz Louro ([@hmcl](https://github.com/hmcl))
## Contributors
http://git-wip-us.apache.org/repos/asf/storm/blob/d6aac4cc/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d666977..a87d922 100644
--- a/pom.xml
+++ b/pom.xml
@@ -183,6 +183,15 @@
</roles>
<timezone>+8</timezone>
</developer>
+ <developer>
+ <id>hmclouro</id>
+ <name>Hugo da Cruz Louro</name>
+ <email>hmclouro@apache.org</email>
+ <roles>
+ <role>Committer</role>
+ </roles>
+ <timezone>-8</timezone>
+ </developer>
</developers>
[03/40] storm git commit: fix yaml front matter for kafka
documentation
Posted by ka...@apache.org.
fix yaml front matter for kafka documentation
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/0f5c185e
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/0f5c185e
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/0f5c185e
Branch: refs/heads/1.1.x-branch
Commit: 0f5c185e546dd27ffbc536c516aa0ffe0a7711d9
Parents: dc2d321
Author: P. Taylor Goetz <pt...@gmail.com>
Authored: Thu Mar 30 11:44:06 2017 -0400
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:23:29 2017 +0900
----------------------------------------------------------------------
docs/storm-kafka-client.md | 5 +++++
docs/storm-kafka.md | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/0f5c185e/docs/storm-kafka-client.md
----------------------------------------------------------------------
diff --git a/docs/storm-kafka-client.md b/docs/storm-kafka-client.md
index 215f60f..d1776d2 100644
--- a/docs/storm-kafka-client.md
+++ b/docs/storm-kafka-client.md
@@ -1,3 +1,8 @@
+---
+title: Storm Kafka Integration (0.10.x+)
+layout: documentation
+documentation: true
+---
#Storm Apache Kafka integration using the kafka-client jar
This includes the new Apache Kafka consumer API.
http://git-wip-us.apache.org/repos/asf/storm/blob/0f5c185e/docs/storm-kafka.md
----------------------------------------------------------------------
diff --git a/docs/storm-kafka.md b/docs/storm-kafka.md
index 37ab05a..c69845d 100644
--- a/docs/storm-kafka.md
+++ b/docs/storm-kafka.md
@@ -1,5 +1,5 @@
---
-title: Storm Kafka Integration
+title: Storm Kafka Integration (0.8.x)
layout: documentation
documentation: true
---
[18/40] storm git commit: STORM-2481 Upgrade Aether version to
resolve Aether bug BUG-451566
Posted by ka...@apache.org.
STORM-2481 Upgrade Aether version to resolve Aether bug BUG-451566
* this resolves NPE issue on Aether and helps showing proper error message
* this also fixes the bug which dependencies root directorys does not exist
* after the patch it will create the directory if not found
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/2f74ca02
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/2f74ca02
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/2f74ca02
Branch: refs/heads/1.1.x-branch
Commit: 2f74ca0282417a781e4672f63b12ab971ea42c39
Parents: 79f33c8
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Tue Apr 18 10:45:04 2017 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:38:39 2017 +0900
----------------------------------------------------------------------
external/storm-submit-tools/pom.xml | 132 ++++++++-----------
.../submit/command/DependencyResolverMain.java | 12 +-
.../storm/submit/dependency/AetherUtils.java | 14 +-
.../apache/storm/submit/dependency/Booter.java | 21 +--
.../submit/dependency/DependencyResolver.java | 24 ++--
.../dependency/RepositorySystemFactory.java | 65 ++++-----
.../submit/dependency/AetherUtilsTest.java | 10 +-
.../dependency/DependencyResolverTest.java | 8 +-
pom.xml | 2 +-
9 files changed, 125 insertions(+), 163 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/2f74ca02/external/storm-submit-tools/pom.xml
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/pom.xml b/external/storm-submit-tools/pom.xml
index 599f98c..7fc25a5 100644
--- a/external/storm-submit-tools/pom.xml
+++ b/external/storm-submit-tools/pom.xml
@@ -44,118 +44,86 @@
<!-- Aether :: maven dependency resolution -->
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>3.0</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.sonatype.sisu</groupId>
- <artifactId>sisu-inject-plexus</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-api</artifactId>
+ <version>${aetherVersion}</version>
</dependency>
<dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-api</artifactId>
- <version>1.12</version>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-spi</artifactId>
+ <version>${aetherVersion}</version>
</dependency>
<dependency>
- <groupId>org.sonatype.aether</groupId>
+ <groupId>org.eclipse.aether</groupId>
<artifactId>aether-util</artifactId>
- <version>1.12</version>
+ <version>${aetherVersion}</version>
</dependency>
<dependency>
- <groupId>org.sonatype.aether</groupId>
+ <groupId>org.eclipse.aether</groupId>
<artifactId>aether-impl</artifactId>
- <version>1.12</version>
+ <version>${aetherVersion}</version>
</dependency>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-aether-provider</artifactId>
- <version>3.0.3</version>
- <exclusions>
- <exclusion>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-spi</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-util</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-impl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-connector-basic</artifactId>
+ <version>${aetherVersion}</version>
</dependency>
<dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-connector-file</artifactId>
- <version>1.12</version>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-transport-file</artifactId>
+ <version>${aetherVersion}</version>
</dependency>
<dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-connector-wagon</artifactId>
- <version>1.12</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-api</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-transport-http</artifactId>
+ <version>${aetherVersion}</version>
</dependency>
<dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-api</artifactId>
- <version>1.0</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-aether-provider</artifactId>
+ <version>${mavenVersion}</version>
</dependency>
<dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-http-lightweight</artifactId>
- <version>1.0</version>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>2.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.plexus</artifactId>
+ <version>0.1.1</version>
+ <optional>true</optional>
<exclusions>
<exclusion>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-http-shared</artifactId>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
</exclusion>
</exclusions>
</dependency>
-
<dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-http</artifactId>
- <version>1.0</version>
+ <groupId>org.sonatype.sisu</groupId>
+ <artifactId>sisu-guice</artifactId>
+ <version>3.1.6</version>
+ <classifier>no_aop</classifier>
+ <optional>true</optional>
<exclusions>
+ <exclusion>
+ <groupId>aopalliance</groupId>
+ <artifactId>aopalliance</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ </exclusion>
</exclusions>
</dependency>
@@ -166,6 +134,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.5</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/storm/blob/2f74ca02/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
index 6c96add..26cd124 100644
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
+++ b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
@@ -24,10 +24,10 @@ import org.apache.commons.lang.StringUtils;
import org.apache.storm.submit.dependency.AetherUtils;
import org.apache.storm.submit.dependency.DependencyResolver;
import org.json.simple.JSONValue;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.ArtifactResult;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactResult;
import java.io.File;
import java.nio.file.Files;
@@ -66,6 +66,10 @@ public class DependencyResolverMain {
try {
String localMavenRepoPath = getOrDefaultLocalMavenRepositoryPath("local-repo");
+
+ // create root directory if not exist
+ Files.createDirectories(new File(localMavenRepoPath).toPath());
+
DependencyResolver resolver = new DependencyResolver(localMavenRepoPath, repositories);
List<ArtifactResult> artifactResults = resolver.resolve(dependencies);
http://git-wip-us.apache.org/repos/asf/storm/blob/2f74ca02/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/AetherUtils.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/AetherUtils.java b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/AetherUtils.java
index a84db39..e1e8ca5 100644
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/AetherUtils.java
+++ b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/AetherUtils.java
@@ -17,12 +17,12 @@
*/
package org.apache.storm.submit.dependency;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.Exclusion;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.artifact.JavaScopes;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.Exclusion;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.util.artifact.JavaScopes;
import java.util.ArrayList;
import java.util.Arrays;
@@ -86,6 +86,6 @@ public class AetherUtils {
throw new IllegalArgumentException("Bad remote repository form: " + repository);
}
- return new RemoteRepository(parts[0], "default", parts[1]);
+ return new RemoteRepository.Builder(parts[0], "default", parts[1]).build();
}
}
http://git-wip-us.apache.org/repos/asf/storm/blob/2f74ca02/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
index 0356e30..31a6c50 100644
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
+++ b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
@@ -18,11 +18,12 @@
package org.apache.storm.submit.dependency;
-import org.apache.maven.repository.internal.MavenRepositorySystemSession;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.repository.LocalRepository;
-import org.sonatype.aether.repository.RemoteRepository;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
import java.io.File;
@@ -36,21 +37,21 @@ public class Booter {
public static RepositorySystemSession newRepositorySystemSession(
RepositorySystem system, String localRepoPath) {
- MavenRepositorySystemSession session = new MavenRepositorySystemSession();
+ DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepo =
new LocalRepository(new File(localRepoPath).getAbsolutePath());
- session.setLocalRepositoryManager(system.newLocalRepositoryManager(localRepo));
+ session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
return session;
}
public static RemoteRepository newCentralRepository() {
- return new RemoteRepository("central", "default", "http://repo1.maven.org/maven2/");
+ return new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/").build();
}
public static RemoteRepository newLocalRepository() {
- return new RemoteRepository("local",
- "default", "file://" + System.getProperty("user.home") + "/.m2/repository");
+ return new RemoteRepository.Builder("local",
+ "default", "file://" + System.getProperty("user.home") + "/.m2/repository").build();
}
}
http://git-wip-us.apache.org/repos/asf/storm/blob/2f74ca02/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
index a6dc4a2..1953b75 100644
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
+++ b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
@@ -18,18 +18,18 @@
package org.apache.storm.submit.dependency;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.collection.CollectRequest;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.DependencyFilter;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.ArtifactResolutionException;
-import org.sonatype.aether.resolution.ArtifactResult;
-import org.sonatype.aether.resolution.DependencyRequest;
-import org.sonatype.aether.resolution.DependencyResolutionException;
-import org.sonatype.aether.util.artifact.JavaScopes;
-import org.sonatype.aether.util.filter.DependencyFilterUtils;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactResolutionException;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.resolution.DependencyRequest;
+import org.eclipse.aether.resolution.DependencyResolutionException;
+import org.eclipse.aether.util.artifact.JavaScopes;
+import org.eclipse.aether.util.filter.DependencyFilterUtils;
import java.io.File;
import java.net.MalformedURLException;
http://git-wip-us.apache.org/repos/asf/storm/blob/2f74ca02/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/RepositorySystemFactory.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/RepositorySystemFactory.java b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/RepositorySystemFactory.java
index 5d60732..ae1c03a 100644
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/RepositorySystemFactory.java
+++ b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/RepositorySystemFactory.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <p>
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
* 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.
@@ -18,50 +18,33 @@
package org.apache.storm.submit.dependency;
-import org.apache.maven.repository.internal.DefaultServiceLocator;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.providers.http.HttpWagon;
-import org.apache.maven.wagon.providers.http.LightweightHttpWagon;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.connector.file.FileRepositoryConnectorFactory;
-import org.sonatype.aether.connector.wagon.WagonProvider;
-import org.sonatype.aether.connector.wagon.WagonRepositoryConnectorFactory;
-import org.sonatype.aether.spi.connector.RepositoryConnectorFactory;
+import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
+import org.eclipse.aether.impl.DefaultServiceLocator;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.spi.connector.transport.TransporterFactory;
+import org.eclipse.aether.transport.file.FileTransporterFactory;
+import org.eclipse.aether.transport.http.HttpTransporterFactory;
+import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
/**
* Get maven repository instance.
*/
public class RepositorySystemFactory {
- public static RepositorySystem newRepositorySystem() {
- DefaultServiceLocator locator = new DefaultServiceLocator();
- locator.addService(RepositoryConnectorFactory.class, FileRepositoryConnectorFactory.class);
- locator.addService(RepositoryConnectorFactory.class, WagonRepositoryConnectorFactory.class);
- locator.setServices(WagonProvider.class, new ManualWagonProvider());
-
- return locator.getService(RepositorySystem.class);
- }
-
- /**
- * ManualWagonProvider
- */
- public static class ManualWagonProvider implements WagonProvider {
-
- @Override
- public Wagon lookup(String roleHint) throws Exception {
- if ("http".equals(roleHint)) {
- return new LightweightHttpWagon();
- }
-
- if ("https".equals(roleHint)) {
- return new HttpWagon();
- }
-
- return null;
+ public static RepositorySystem newRepositorySystem() {
+ DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
+ locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
+ locator.addService(TransporterFactory.class, FileTransporterFactory.class);
+ locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
+
+ locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
+ @Override
+ public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
+ exception.printStackTrace();
+ }
+ });
+
+ return locator.getService(RepositorySystem.class);
}
- @Override
- public void release(Wagon arg0) {
-
- }
- }
}
http://git-wip-us.apache.org/repos/asf/storm/blob/2f74ca02/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/AetherUtilsTest.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/AetherUtilsTest.java b/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/AetherUtilsTest.java
index 9951621..5b5ce3e 100644
--- a/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/AetherUtilsTest.java
+++ b/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/AetherUtilsTest.java
@@ -19,11 +19,11 @@ package org.apache.storm.submit.dependency;
import com.google.common.collect.Lists;
import org.junit.Test;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.Exclusion;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.artifact.JavaScopes;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.Exclusion;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.util.artifact.JavaScopes;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/storm/blob/2f74ca02/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/DependencyResolverTest.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/DependencyResolverTest.java b/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/DependencyResolverTest.java
index 086abad..8f7b750 100644
--- a/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/DependencyResolverTest.java
+++ b/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/DependencyResolverTest.java
@@ -23,10 +23,10 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.resolution.ArtifactResult;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.artifact.JavaScopes;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.util.artifact.JavaScopes;
import java.nio.file.Files;
import java.nio.file.Path;
http://git-wip-us.apache.org/repos/asf/storm/blob/2f74ca02/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a87d922..bf54381 100644
--- a/pom.xml
+++ b/pom.xml
@@ -284,7 +284,7 @@
<!-- by default the clojure test set are all clojure tests that are not integration tests. This property is overridden in the profiles -->
<clojure.test.set>!integration.*</clojure.test.set>
- <aetherVersion>1.0.0.v20140518</aetherVersion>
+ <aetherVersion>1.1.0</aetherVersion>
<mavenVersion>3.1.0</mavenVersion>
<wagonVersion>1.0</wagonVersion>
<qpid.version>0.32</qpid.version>
[40/40] storm git commit: Bulk update CHANGELOG for porting back
Posted by ka...@apache.org.
Bulk update CHANGELOG for porting back
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/81e9d657
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/81e9d657
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/81e9d657
Branch: refs/heads/1.1.x-branch
Commit: 81e9d65793abc5defc0ab83c09b26a7dcba7e0eb
Parents: 9cfb123
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Thu Jun 29 17:02:49 2017 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 17:02:49 2017 +0900
----------------------------------------------------------------------
CHANGELOG.md | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/81e9d657/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 68fbab3..3544329 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,39 @@
-## 1.1.0
+## 1.1.1
+ * STORM-2564: We should provide a template for storm-cluster-auth.yaml
+ * STORM-2568: Fix getTopicsString
+ * STORM-2563: Remove the workaround to handle missing UGI.loginUserFromSubject
+ * STORM-2552: KafkaSpoutMessageId should be serializable
+ * STORM-2562: Use stronger key size than default for blow fish key generator and get rid of stack trace
+ * STORM-2557: A bug in DisruptorQueue causing severe underestimation of queue arrival rates
+ * STORM-2449: Ensure same key appears only once in State iterator
+ * STORM-2516: Fix timing issues with testPrepareLateTupleStreamWithoutBuilder
+ * STORM-2489: Overlap and data loss on WindowedBolt based on Duration
+ * STORM-2528: Bump log4j version to 2.8.2
+ * STORM-2527: Initialize java.sql.DriverManager earlier to avoid deadlock
+ * STORM-2413: Make new Kafka spout respect tuple retry limits
+ * STORM-2518: Handles empty name for "USER type" ACL when normalizing ACLs
+ * STORM-2511: Submitting a topology with name containing unicode getting failed
+ * STORM-2496: Dependency artifacts should be uploaded to blobstore with READ permission for all
+ * STORM-2505: Spout to support topic compaction
+ * STORM-2498: Fix Download Full File link
+ * STORM-2343: New Kafka spout can stop emitting tuples if more than maxUncommittedOffsets tuples fail at once.
+ * STORM-2486: Prevent cd from printing target directory to avoid breaking classpath
+ * STORM-2488: The UI user Must be HTTP.
+ * STORM-2481: Upgrade Aether version to resolve Aether bug BUG-451566
+ * STORM-2435: Logging in storm.js inconsistent to console.log and does not support log levels
+ * STORM-2315: New kafka spout can't commit offset when ack is disabled
+ * STORM-2467: Use explicit charset when decoding from array backed buffer
+ * STORM-1114: Race condition in trident zookeeper zk-node create/delete
+ * STORM-2448: Add in Storm and JDK versions when submitting a topology
+ * STORM-2343: Fix new Kafka spout stopping processing if more than maxUncommittedOffsets tuples fail at once
+ * STORM-2431: the default blobstore.dir is storm.local.dir/blobs which is different from distcache-blobstore.md
+ * STORM-2429: Properly validate supervisor.scheduler.meta
+ * STORM-2451: windows storm.cmd does not set log4j2 config file correctly by default
+ * STORM-2450: Write resources into correct local director
+ * STORM-2440: Kill process if executor catches `java.net.SocketTimeoutException`
+ * STORM-2432: Storm-Kafka-Client Trident Spout Seeks Incorrect Offset With UNCOMMITTED_LATEST Strategy
+
+## 1.1.0
* STORM-2425: Storm Hive Bolt not closing open transactions
* STORM-2409: Storm-Kafka-Client KafkaSpout Support for Failed and NullTuples
* STORM-2423: Join Bolt should use explicit instead of default window anchoring for emitted tuples
[19/40] storm git commit: Merge branch 'patch-1' of
https://github.com/MichealShin/storm
Posted by ka...@apache.org.
Merge branch 'patch-1' of https://github.com/MichealShin/storm
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/488b0158
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/488b0158
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/488b0158
Branch: refs/heads/1.1.x-branch
Commit: 488b0158645a1a9d9069b6ff6d646d6be981cbf0
Parents: 2f74ca0
Author: Sriharsha Chintalapani <ha...@hortonworks.com>
Authored: Tue Apr 25 20:40:08 2017 -0700
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:39:42 2017 +0900
----------------------------------------------------------------------
docs/SECURITY.md | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/488b0158/docs/SECURITY.md
----------------------------------------------------------------------
diff --git a/docs/SECURITY.md b/docs/SECURITY.md
index a9d0d7f..66566ce 100644
--- a/docs/SECURITY.md
+++ b/docs/SECURITY.md
@@ -74,6 +74,7 @@ ui.filter.params:
"kerberos.name.rules": "RULE:[2:$1@$0]([jt]t@.*EXAMPLE.COM)s/.*/$MAPRED_USER/ RULE:[2:$1@$0]([nd]n@.*EXAMPLE.COM)s/.*/$HDFS_USER/DEFAULT"
```
make sure to create a principal 'HTTP/{hostname}' (here hostname should be the one where UI daemon runs
+Be aware that the UI user *MUST* be HTTP.
Once configured users needs to do kinit before accessing UI.
Ex:
[23/40] storm git commit: [STORM-2505] Spout to support topic
compaction
Posted by ka...@apache.org.
[STORM-2505] Spout to support topic compaction
[STORM-2505] Maintaining a emitted set in OffsetManager to handle the voids in the topic
[STORM-2505] Handling NPE in Boxed Long to primitive type comparison
[STORM-2505] Rephrased the log message when a non contiguous offset is acked by the spout
[STORM-2505] Updated comment
[STORM-2505] Renamed the methods ack/emit to addToAckMsgs and addToEmitMsgs in OffsetManager
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/97605c1b
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/97605c1b
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/97605c1b
Branch: refs/heads/1.1.x-branch
Commit: 97605c1b1bd1fc286facaf36ceeb85fd31298fdf
Parents: 796e715
Author: Vivek Mittal <vi...@flipkart.com>
Authored: Mon May 8 10:43:36 2017 +0530
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:45:44 2017 +0900
----------------------------------------------------------------------
.../apache/storm/kafka/spout/KafkaSpout.java | 21 ++++-----
.../kafka/spout/internal/OffsetManager.java | 47 +++++++++++++++++---
2 files changed, 53 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/97605c1b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
index 47c305b..32542b9 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
@@ -77,7 +77,7 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
private transient boolean initialized; // Flag indicating that the spout is still undergoing initialization process.
// Initialization is only complete after the first call to KafkaSpoutConsumerRebalanceListener.onPartitionsAssigned()
- private transient Map<TopicPartition, OffsetManager> acked; // Tuples that were successfully acked. These tuples will be committed periodically when the commit timer expires, or after a consumer rebalance, or during close/deactivate
+ private transient Map<TopicPartition, OffsetManager> offsetManagers;// Tuples that were successfully acked/emitted. These tuples will be committed periodically when the commit timer expires, or after a consumer rebalance, or during close/deactivate
private transient Set<KafkaSpoutMessageId> emitted; // Tuples that have been emitted but that are "on the wire", i.e. pending being acked or failed. Not used if it's AutoCommitMode
private transient Iterator<ConsumerRecord<K, V>> waitingToEmit; // Records that have been polled and are queued to be emitted in the nextTuple() call. One record is emitted per nextTuple()
private transient long numUncommittedOffsets; // Number of offsets that have been polled and emitted but not yet been committed. Not used if auto commit mode is enabled.
@@ -117,7 +117,7 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
}
refreshSubscriptionTimer = new Timer(TIMER_DELAY_MS, kafkaSpoutConfig.getPartitionRefreshPeriodMs(), TimeUnit.MILLISECONDS);
- acked = new HashMap<>();
+ offsetManagers = new HashMap<>();
emitted = new HashSet<>();
waitingToEmit = Collections.emptyListIterator();
@@ -147,7 +147,7 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
private void initialize(Collection<TopicPartition> partitions) {
if (!consumerAutoCommitMode) {
- acked.keySet().retainAll(partitions); // remove from acked all partitions that are no longer assigned to this spout
+ offsetManagers.keySet().retainAll(partitions); // remove from acked all partitions that are no longer assigned to this spout
}
retryService.retainAll(partitions);
@@ -205,8 +205,8 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
private void setAcked(TopicPartition tp, long fetchOffset) {
// If this partition was previously assigned to this spout, leave the acked offsets as they were to resume where it left off
- if (!consumerAutoCommitMode && !acked.containsKey(tp)) {
- acked.put(tp, new OffsetManager(tp, fetchOffset));
+ if (!consumerAutoCommitMode && !offsetManagers.containsKey(tp)) {
+ offsetManagers.put(tp, new OffsetManager(tp, fetchOffset));
}
}
@@ -319,7 +319,7 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
private boolean emitTupleIfNotEmitted(ConsumerRecord<K, V> record) {
final TopicPartition tp = new TopicPartition(record.topic(), record.partition());
final KafkaSpoutMessageId msgId = new KafkaSpoutMessageId(record);
- if (acked.containsKey(tp) && acked.get(tp).contains(msgId)) { // has been acked
+ if (offsetManagers.containsKey(tp) && offsetManagers.get(tp).contains(msgId)) { // has been acked
LOG.trace("Tuple for record [{}] has already been acked. Skipping", record);
} else if (emitted.contains(msgId)) { // has been emitted and it's pending ack or fail
LOG.trace("Tuple for record [{}] has already been emitted. Skipping", record);
@@ -337,6 +337,7 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
}
} else {
emitted.add(msgId);
+ offsetManagers.get(tp).addToEmitMsgs(msgId.offset());
if (isScheduled) { // Was scheduled for retry and re-emitted, so remove from schedule.
retryService.remove(msgId);
} else { //New tuple, hence increment the uncommitted offset counter
@@ -371,7 +372,7 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
private void commitOffsetsForAckedTuples() {
// Find offsets that are ready to be committed for every topic partition
final Map<TopicPartition, OffsetAndMetadata> nextCommitOffsets = new HashMap<>();
- for (Map.Entry<TopicPartition, OffsetManager> tpOffset : acked.entrySet()) {
+ for (Map.Entry<TopicPartition, OffsetManager> tpOffset : offsetManagers.entrySet()) {
final OffsetAndMetadata nextCommitOffset = tpOffset.getValue().findNextCommitOffset();
if (nextCommitOffset != null) {
nextCommitOffsets.put(tpOffset.getKey(), nextCommitOffset);
@@ -387,7 +388,7 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
for (Map.Entry<TopicPartition, OffsetAndMetadata> tpOffset : nextCommitOffsets.entrySet()) {
//Update the OffsetManager for each committed partition, and update numUncommittedOffsets
final TopicPartition tp = tpOffset.getKey();
- final OffsetManager offsetManager = acked.get(tp);
+ final OffsetManager offsetManager = offsetManagers.get(tp);
long numCommittedOffsets = offsetManager.commit(tpOffset.getValue());
numUncommittedOffsets -= numCommittedOffsets;
LOG.debug("[{}] uncommitted offsets across all topic partitions",
@@ -413,7 +414,7 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
}
} else {
if (!consumerAutoCommitMode) { // Only need to keep track of acked tuples if commits are not done automatically
- acked.get(msgId.getTopicPartition()).add(msgId);
+ offsetManagers.get(msgId.getTopicPartition()).addToAckMsgs(msgId);
}
emitted.remove(msgId);
}
@@ -493,7 +494,7 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
@Override
public String toString() {
return "KafkaSpout{" +
- "acked=" + acked +
+ "offsetManagers =" + offsetManagers +
", emitted=" + emitted +
"}";
}
http://git-wip-us.apache.org/repos/asf/storm/blob/97605c1b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/internal/OffsetManager.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/internal/OffsetManager.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/internal/OffsetManager.java
index 4ce0471..0bf4132 100755
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/internal/OffsetManager.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/internal/OffsetManager.java
@@ -39,6 +39,8 @@ public class OffsetManager {
private final long initialFetchOffset;
// Last offset committed to Kafka. Initially it is set to fetchOffset - 1
private long committedOffset;
+ // Emitted Offsets List
+ private final NavigableSet<Long> emittedOffsets = new TreeSet<>();
// Acked messages sorted by ascending order of offset
private final NavigableSet<KafkaSpoutMessageId> ackedMsgs = new TreeSet<>(OFFSET_COMPARATOR);
@@ -49,10 +51,14 @@ public class OffsetManager {
LOG.debug("Instantiated {}", this);
}
- public void add(KafkaSpoutMessageId msgId) { // O(Log N)
+ public void addToAckMsgs(KafkaSpoutMessageId msgId) { // O(Log N)
ackedMsgs.add(msgId);
}
+ public void addToEmitMsgs(long offset) {
+ this.emittedOffsets.add(offset); // O(Log N)
+ }
+
/**
* An offset is only committed when all records with lower offset have been
* acked. This guarantees that all offsets smaller than the committedOffset
@@ -68,13 +74,34 @@ public class OffsetManager {
KafkaSpoutMessageId nextCommitMsg = null; // this is a convenience variable to make it faster to create OffsetAndMetadata
for (KafkaSpoutMessageId currAckedMsg : ackedMsgs) { // complexity is that of a linear scan on a TreeMap
- if ((currOffset = currAckedMsg.offset()) == nextCommitOffset + 1) { // found the next offset to commit
+ currOffset = currAckedMsg.offset();
+ if (currOffset == nextCommitOffset + 1) { // found the next offset to commit
found = true;
nextCommitMsg = currAckedMsg;
nextCommitOffset = currOffset;
- } else if (currAckedMsg.offset() > nextCommitOffset + 1) { // offset found is not continuous to the offsets listed to go in the next commit, so stop search
- LOG.debug("topic-partition [{}] has non-continuous offset [{}]. It will be processed in a subsequent batch.", tp, currOffset);
- break;
+ } else if (currOffset > nextCommitOffset + 1) {
+ if (emittedOffsets.contains(nextCommitOffset + 1)) {
+ LOG.debug("topic-partition [{}] has non-continuous offset [{}]. It will be processed in a subsequent batch.", tp, currOffset);
+ break;
+ } else {
+ /*
+ This case will arise in case of non contiguous offset being processed.
+ So, if the topic doesn't contain offset = committedOffset + 1 (possible
+ if the topic is compacted or deleted), the consumer should jump to
+ the next logical point in the topic. Next logical offset should be the
+ first element after committedOffset in the ascending ordered emitted set.
+ */
+ LOG.debug("Processed non contiguous offset. (committedOffset+1) is no longer part of the topic. Committed: [{}], Processed: [{}]", committedOffset, currOffset);
+ final Long nextEmittedOffset = emittedOffsets.ceiling(nextCommitOffset);
+ if (nextEmittedOffset != null && currOffset == nextEmittedOffset) {
+ found = true;
+ nextCommitMsg = currAckedMsg;
+ nextCommitOffset = currOffset;
+ } else {
+ LOG.debug("topic-partition [{}] has non-continuous offset [{}]. Next Offset to commit should be [{}]", tp, currOffset, nextEmittedOffset);
+ break;
+ }
+ }
} else {
//Received a redundant ack. Ignore and continue processing.
LOG.warn("topic-partition [{}] has unexpected offset [{}]. Current committed Offset [{}]",
@@ -113,6 +140,15 @@ public class OffsetManager {
break;
}
}
+
+ for (Iterator<Long> iterator = emittedOffsets.iterator(); iterator.hasNext();) {
+ if (iterator.next() <= committedOffset.offset()) {
+ iterator.remove();
+ } else {
+ break;
+ }
+ }
+
LOG.trace("{}", this);
LOG.debug("Committed offsets [{}-{} = {}] for topic-partition [{}].",
@@ -143,6 +179,7 @@ public class OffsetManager {
+ "topic-partition=" + tp
+ ", fetchOffset=" + initialFetchOffset
+ ", committedOffset=" + committedOffset
+ + ", emittedOffsets=" + emittedOffsets
+ ", ackedMsgs=" + ackedMsgs
+ '}';
}
[25/40] storm git commit: STORM-2518 Handles empty name for "USER
type" ACL when normalizing ACLs
Posted by ka...@apache.org.
STORM-2518 Handles empty name for "USER type" ACL when normalizing ACLs
* if ACLs have both empty name and user, discard empty name ACLs
* add default ACL for user when neither empty name nor user ACL exists
* populate empty name ACLs to users in Subject: set name to user for each
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/bb908f61
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/bb908f61
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/bb908f61
Branch: refs/heads/1.1.x-branch
Commit: bb908f61acd5301ea831158fe1e9b55c34b747ac
Parents: 5a721d7
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Wed May 17 17:45:44 2017 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:48:54 2017 +0900
----------------------------------------------------------------------
.../storm/blobstore/BlobStoreAclHandler.java | 52 +++++++++++++++++---
1 file changed, 45 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/bb908f61/storm-core/src/jvm/org/apache/storm/blobstore/BlobStoreAclHandler.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/blobstore/BlobStoreAclHandler.java b/storm-core/src/jvm/org/apache/storm/blobstore/BlobStoreAclHandler.java
index 5b3866d..89fe165 100644
--- a/storm-core/src/jvm/org/apache/storm/blobstore/BlobStoreAclHandler.java
+++ b/storm-core/src/jvm/org/apache/storm/blobstore/BlobStoreAclHandler.java
@@ -356,6 +356,7 @@ public class BlobStoreAclHandler {
for (String user : userNames) {
fixACLsForUser(cleanAcls, user, opMask);
}
+ fixEmptyNameACLForUsers(cleanAcls, userNames, opMask);
if ((who == null || userNames.isEmpty()) && !worldEverything(acls)) {
cleanAcls.addAll(BlobStoreAclHandler.WORLD_EVERYTHING);
LOG.debug("Access Control for key {} is normalized to world everything {}", key, cleanAcls);
@@ -378,17 +379,29 @@ public class BlobStoreAclHandler {
private void fixACLsForUser(List<AccessControl> acls, String user, int mask) {
boolean foundUserACL = false;
+ List<AccessControl> emptyUserACLs = new ArrayList<>();
+
for (AccessControl control : acls) {
- if (control.get_type() == AccessControlType.USER && control.get_name().equals(user)) {
- int currentAccess = control.get_access();
- if ((currentAccess & mask) != mask) {
- control.set_access(currentAccess | mask);
+ if (control.get_type() == AccessControlType.USER) {
+ if (!control.is_set_name()) {
+ emptyUserACLs.add(control);
+ } else if (control.get_name().equals(user)) {
+ int currentAccess = control.get_access();
+ if ((currentAccess & mask) != mask) {
+ control.set_access(currentAccess | mask);
+ }
+ foundUserACL = true;
}
- foundUserACL = true;
- break;
}
}
- if (!foundUserACL) {
+
+ // if ACLs have two user ACLs for empty user and principal, discard empty user ACL
+ if (!emptyUserACLs.isEmpty() && foundUserACL) {
+ acls.removeAll(emptyUserACLs);
+ }
+
+ // add default user ACL when only empty user ACL is not present
+ if (emptyUserACLs.isEmpty() && !foundUserACL) {
AccessControl userACL = new AccessControl();
userACL.set_type(AccessControlType.USER);
userACL.set_name(user);
@@ -397,6 +410,31 @@ public class BlobStoreAclHandler {
}
}
+ private void fixEmptyNameACLForUsers(List<AccessControl> acls, Set<String> users, int mask) {
+ List<AccessControl> aclsToAdd = new ArrayList<>();
+ List<AccessControl> aclsToRemove = new ArrayList<>();
+
+ for (AccessControl control : acls) {
+ if (control.get_type() == AccessControlType.USER && !control.is_set_name()) {
+ aclsToRemove.add(control);
+
+ int currentAccess = control.get_access();
+ if ((currentAccess & mask) != mask) {
+ control.set_access(currentAccess | mask);
+ }
+
+ for (String user : users) {
+ AccessControl copiedControl = new AccessControl(control);
+ copiedControl.set_name(user);
+ aclsToAdd.add(copiedControl);
+ }
+ }
+ }
+
+ acls.removeAll(aclsToRemove);
+ acls.addAll(aclsToAdd);
+ }
+
private Set<String> getUserNamesFromSubject(Subject who) {
Set<String> user = new HashSet<String>();
if (who != null) {
[21/40] storm git commit: [STORM-2498] Fix Download Full File link in
1.x branch
Posted by ka...@apache.org.
[STORM-2498] Fix Download Full File link in 1.x branch
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/a265929a
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/a265929a
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/a265929a
Branch: refs/heads/1.1.x-branch
Commit: a265929a5ff94fa41a982b3c574cbc6b96f38601
Parents: 711115f
Author: Arun Mahadevan <ar...@apache.org>
Authored: Wed May 3 13:23:24 2017 +0530
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:42:43 2017 +0900
----------------------------------------------------------------------
storm-core/src/clj/org/apache/storm/daemon/logviewer.clj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/a265929a/storm-core/src/clj/org/apache/storm/daemon/logviewer.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/org/apache/storm/daemon/logviewer.clj b/storm-core/src/clj/org/apache/storm/daemon/logviewer.clj
index a5b2ee8..d7b21de 100644
--- a/storm-core/src/clj/org/apache/storm/daemon/logviewer.clj
+++ b/storm-core/src/clj/org/apache/storm/daemon/logviewer.clj
@@ -396,7 +396,7 @@
"Next" :enabled (> next-start start))])]]))
(defn- download-link [fname]
- [[:p (link-to (url-format "/download?file=%s" (to-array [fname])) "Download Full File")]])
+ [[:p (link-to (url-format "/download?file=%s" fname) "Download Full File")]])
(defn- daemon-download-link [fname]
[[:p (link-to (url-format "/daemondownload/%s" fname) "Download Full File")]])
[10/40] storm git commit: STORM-2343: Fix new Kafka spout stopping
processing if more than maxUncommittedOffsets tuples fail at once
Posted by ka...@apache.org.
STORM-2343: Fix new Kafka spout stopping processing if more than maxUncommittedOffsets tuples fail at once
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/fe16fd40
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/fe16fd40
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/fe16fd40
Branch: refs/heads/1.1.x-branch
Commit: fe16fd40c69d872e0a2cd5a5dd0bc39fbf72cd9d
Parents: 29c349d
Author: Stig Rohde Døssing <sd...@it-minds.dk>
Authored: Sat Apr 8 08:26:42 2017 +0200
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:29:34 2017 +0900
----------------------------------------------------------------------
.../apache/storm/kafka/spout/KafkaSpout.java | 26 +-
.../storm/kafka/spout/KafkaSpoutConfig.java | 10 +-
.../KafkaSpoutRetryExponentialBackoff.java | 78 ++++--
.../kafka/spout/KafkaSpoutRetryService.java | 10 +-
.../storm/kafka/spout/KafkaSpoutEmitTest.java | 256 +++++++++++++++++++
.../kafka/spout/KafkaSpoutRebalanceTest.java | 11 +-
.../kafka/spout/MaxUncommittedOffsetTest.java | 245 ++++++++++++++++++
.../kafka/spout/SingleTopicKafkaSpoutTest.java | 45 +++-
.../SingleTopicKafkaSpoutConfiguration.java | 19 +-
9 files changed, 633 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/fe16fd40/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
index 207ba23..0bfcfea 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
@@ -31,6 +31,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -79,7 +80,7 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
private transient Map<TopicPartition, OffsetManager> acked; // Tuples that were successfully acked. These tuples will be committed periodically when the commit timer expires, or after a consumer rebalance, or during close/deactivate
private transient Set<KafkaSpoutMessageId> emitted; // Tuples that have been emitted but that are "on the wire", i.e. pending being acked or failed. Not used if it's AutoCommitMode
private transient Iterator<ConsumerRecord<K, V>> waitingToEmit; // Records that have been polled and are queued to be emitted in the nextTuple() call. One record is emitted per nextTuple()
- private transient long numUncommittedOffsets; // Number of offsets that have been polled and emitted but not yet been committed. Not used if it's AutoCommitMode
+ private transient long numUncommittedOffsets; // Number of offsets that have been polled and emitted but not yet been committed. Not used if auto commit mode is enabled.
private transient Timer refreshSubscriptionTimer; // Triggers when a subscription should be refreshed
private transient TopologyContext context;
@@ -250,9 +251,13 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
private boolean poll() {
final int maxUncommittedOffsets = kafkaSpoutConfig.getMaxUncommittedOffsets();
- final boolean poll = !waitingToEmit()
- && (numUncommittedOffsets < maxUncommittedOffsets || consumerAutoCommitMode);
-
+ final int readyMessageCount = retryService.readyMessageCount();
+ final boolean poll = !waitingToEmit() &&
+ //Check that the number of uncommitted, nonretriable tuples is less than the maxUncommittedOffsets limit
+ //Accounting for retriable tuples this way still guarantees that the limit is followed on a per partition basis, and prevents locking up the spout when there are too many retriable tuples
+ (numUncommittedOffsets - readyMessageCount < maxUncommittedOffsets ||
+ consumerAutoCommitMode);
+
if (!poll) {
if (waitingToEmit()) {
LOG.debug("Not polling. Tuples waiting to be emitted. [{}] uncommitted offsets across all topic partitions", numUncommittedOffsets);
@@ -290,15 +295,11 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
}
private void doSeekRetriableTopicPartitions() {
- final Set<TopicPartition> retriableTopicPartitions = retryService.retriableTopicPartitions();
+ final Map<TopicPartition, Long> retriableTopicPartitions = retryService.earliestRetriableOffsets();
- for (TopicPartition rtp : retriableTopicPartitions) {
- final OffsetAndMetadata offsetAndMeta = acked.get(rtp).findNextCommitOffset();
- if (offsetAndMeta != null) {
- kafkaConsumer.seek(rtp, offsetAndMeta.offset() + 1); // seek to the next offset that is ready to commit in next commit cycle
- } else {
- kafkaConsumer.seek(rtp, acked.get(rtp).getCommittedOffset() + 1); // Seek to last committed offset
- }
+ for (Entry<TopicPartition, Long> retriableTopicPartitionAndOffset : retriableTopicPartitions.entrySet()) {
+ //Seek directly to the earliest retriable message for each retriable topic partition
+ kafkaConsumer.seek(retriableTopicPartitionAndOffset.getKey(), retriableTopicPartitionAndOffset.getValue());
}
}
@@ -318,7 +319,6 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
private boolean emitTupleIfNotEmitted(ConsumerRecord<K, V> record) {
final TopicPartition tp = new TopicPartition(record.topic(), record.partition());
final KafkaSpoutMessageId msgId = new KafkaSpoutMessageId(record);
-
if (acked.containsKey(tp) && acked.get(tp).contains(msgId)) { // has been acked
LOG.trace("Tuple for record [{}] has already been acked. Skipping", record);
} else if (emitted.contains(msgId)) { // has been emitted and it's pending ack or fail
http://git-wip-us.apache.org/repos/asf/storm/blob/fe16fd40/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutConfig.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutConfig.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutConfig.java
index 920dca9..5f8071f 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutConfig.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutConfig.java
@@ -269,12 +269,9 @@ public class KafkaSpoutConfig<K, V> implements Serializable {
/**
* The maximum number of records a poll will return.
- * Will only work with Kafka 0.10.0 and above.
*/
public Builder<K,V> setMaxPollRecords(int records) {
- //to avoid issues with 0.9 versions that technically still work
- // with this we do not use ConsumerConfig.MAX_POLL_RECORDS_CONFIG
- return setProp("max.poll.records", records);
+ return setProp(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, records);
}
//Security Related Configs
@@ -330,11 +327,12 @@ public class KafkaSpoutConfig<K, V> implements Serializable {
this.offsetCommitPeriodMs = offsetCommitPeriodMs;
return this;
}
-
+
/**
* Defines the max number of polled offsets (records) that can be pending commit, before another poll can take place.
* Once this limit is reached, no more offsets (records) can be polled until the next successful commit(s) sets the number
- * of pending offsets bellow the threshold. The default is {@link #DEFAULT_MAX_UNCOMMITTED_OFFSETS}.
+ * of pending offsets below the threshold. The default is {@link #DEFAULT_MAX_UNCOMMITTED_OFFSETS}.
+ * Note that this limit can in some cases be exceeded, but no partition will exceed this limit by more than maxPollRecords - 1.
* @param maxUncommittedOffsets max number of records that can be be pending commit
*/
public Builder<K,V> setMaxUncommittedOffsets(int maxUncommittedOffsets) {
http://git-wip-us.apache.org/repos/asf/storm/blob/fe16fd40/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryExponentialBackoff.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryExponentialBackoff.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryExponentialBackoff.java
index 2c8d7e4..2584685 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryExponentialBackoff.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryExponentialBackoff.java
@@ -25,15 +25,18 @@ import org.slf4j.LoggerFactory;
import java.io.Serializable;
import java.util.Collection;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
+import org.apache.storm.utils.Time;
/**
* Implementation of {@link KafkaSpoutRetryService} using the exponential backoff formula. The time of the nextRetry is set as follows:
- * nextRetry = failCount == 1 ? currentTime + initialDelay : currentTime + delayPeriod^(failCount-1) where failCount = 1, 2, 3, ...
+ * nextRetry = failCount == 1 ? currentTime + initialDelay : currentTime + delayPeriod*2^(failCount-1) where failCount = 1, 2, 3, ...
* nextRetry = Min(nextRetry, currentTime + maxDelay)
*/
public class KafkaSpoutRetryExponentialBackoff implements KafkaSpoutRetryService {
@@ -54,7 +57,14 @@ public class KafkaSpoutRetryExponentialBackoff implements KafkaSpoutRetryService
private static class RetryEntryTimeStampComparator implements Serializable, Comparator<RetrySchedule> {
@Override
public int compare(RetrySchedule entry1, RetrySchedule entry2) {
- return Long.valueOf(entry1.nextRetryTimeNanos()).compareTo(entry2.nextRetryTimeNanos());
+ int result = Long.valueOf(entry1.nextRetryTimeNanos()).compareTo(entry2.nextRetryTimeNanos());
+
+ if(result == 0) {
+ //TreeSet uses compareTo instead of equals() for the Set contract
+ //Ensure that we can save two retry schedules with the same timestamp
+ result = entry1.hashCode() - entry2.hashCode();
+ }
+ return result;
}
}
@@ -62,13 +72,13 @@ public class KafkaSpoutRetryExponentialBackoff implements KafkaSpoutRetryService
private final KafkaSpoutMessageId msgId;
private long nextRetryTimeNanos;
- public RetrySchedule(KafkaSpoutMessageId msgId, long nextRetryTime) {
+ public RetrySchedule(KafkaSpoutMessageId msgId, long nextRetryTimeNanos) {
this.msgId = msgId;
- this.nextRetryTimeNanos = nextRetryTime;
+ this.nextRetryTimeNanos = nextRetryTimeNanos;
LOG.debug("Created {}", this);
}
- public void setNextRetryTime() {
+ public void setNextRetryTimeNanos() {
nextRetryTimeNanos = nextTime(msgId);
LOG.debug("Updated {}", this);
}
@@ -81,7 +91,7 @@ public class KafkaSpoutRetryExponentialBackoff implements KafkaSpoutRetryService
public String toString() {
return "RetrySchedule{" +
"msgId=" + msgId +
- ", nextRetryTime=" + nextRetryTimeNanos +
+ ", nextRetryTimeNanos=" + nextRetryTimeNanos +
'}';
}
@@ -96,19 +106,19 @@ public class KafkaSpoutRetryExponentialBackoff implements KafkaSpoutRetryService
public static class TimeInterval implements Serializable {
private final long lengthNanos;
- private final long length;
private final TimeUnit timeUnit;
+ private final long length;
/**
* @param length length of the time interval in the units specified by {@link TimeUnit}
* @param timeUnit unit used to specify a time interval on which to specify a time unit
*/
public TimeInterval(long length, TimeUnit timeUnit) {
- this.length = length;
- this.timeUnit = timeUnit;
this.lengthNanos = timeUnit.toNanos(length);
+ this.timeUnit = timeUnit;
+ this.length = length;
}
-
+
public static TimeInterval seconds(long length) {
return new TimeInterval(length, TimeUnit.SECONDS);
}
@@ -116,19 +126,15 @@ public class KafkaSpoutRetryExponentialBackoff implements KafkaSpoutRetryService
public static TimeInterval milliSeconds(long length) {
return new TimeInterval(length, TimeUnit.MILLISECONDS);
}
-
+
public static TimeInterval microSeconds(long length) {
return new TimeInterval(length, TimeUnit.MICROSECONDS);
}
-
+
public long lengthNanos() {
return lengthNanos;
}
-
- public long length() {
- return length;
- }
-
+
public TimeUnit timeUnit() {
return timeUnit;
}
@@ -165,26 +171,32 @@ public class KafkaSpoutRetryExponentialBackoff implements KafkaSpoutRetryService
}
@Override
- public Set<TopicPartition> retriableTopicPartitions() {
- final Set<TopicPartition> tps = new HashSet<>();
- final long currentTimeNanos = System.nanoTime();
+ public Map<TopicPartition, Long> earliestRetriableOffsets() {
+ final Map<TopicPartition, Long> tpToEarliestRetriableOffset = new HashMap<>();
+ final long currentTimeNanos = Time.nanoTime();
for (RetrySchedule retrySchedule : retrySchedules) {
if (retrySchedule.retry(currentTimeNanos)) {
final KafkaSpoutMessageId msgId = retrySchedule.msgId;
- tps.add(new TopicPartition(msgId.topic(), msgId.partition()));
+ final TopicPartition tpForMessage = new TopicPartition(msgId.topic(), msgId.partition());
+ final Long currentLowestOffset = tpToEarliestRetriableOffset.get(tpForMessage);
+ if(currentLowestOffset != null) {
+ tpToEarliestRetriableOffset.put(tpForMessage, Math.min(currentLowestOffset, msgId.offset()));
+ } else {
+ tpToEarliestRetriableOffset.put(tpForMessage, msgId.offset());
+ }
} else {
break; // Stop searching as soon as passed current time
}
}
- LOG.debug("Topic partitions with entries ready to be retried [{}] ", tps);
- return tps;
+ LOG.debug("Topic partitions with entries ready to be retried [{}] ", tpToEarliestRetriableOffset);
+ return tpToEarliestRetriableOffset;
}
@Override
public boolean isReady(KafkaSpoutMessageId msgId) {
boolean retry = false;
if (toRetryMsgs.contains(msgId)) {
- final long currentTimeNanos = System.nanoTime();
+ final long currentTimeNanos = Time.nanoTime();
for (RetrySchedule retrySchedule : retrySchedules) {
if (retrySchedule.retry(currentTimeNanos)) {
if (retrySchedule.msgId.equals(msgId)) {
@@ -265,13 +277,27 @@ public class KafkaSpoutRetryExponentialBackoff implements KafkaSpoutRetryService
return true;
}
}
+
+ @Override
+ public int readyMessageCount() {
+ int count = 0;
+ final long currentTimeNanos = Time.nanoTime();
+ for (RetrySchedule retrySchedule : retrySchedules) {
+ if (retrySchedule.retry(currentTimeNanos)) {
+ ++count;
+ } else {
+ break; //Stop counting when past current time
+ }
+ }
+ return count;
+ }
// if value is greater than Long.MAX_VALUE it truncates to Long.MAX_VALUE
private long nextTime(KafkaSpoutMessageId msgId) {
- final long currentTimeNanos = System.nanoTime();
+ final long currentTimeNanos = Time.nanoTime();
final long nextTimeNanos = msgId.numFails() == 1 // numFails = 1, 2, 3, ...
? currentTimeNanos + initialDelay.lengthNanos
- : (currentTimeNanos + delayPeriod.timeUnit.toNanos((long) Math.pow(delayPeriod.length, msgId.numFails() - 1)));
+ : currentTimeNanos + delayPeriod.lengthNanos * (long)(Math.pow(2, msgId.numFails()-1));
return Math.min(nextTimeNanos, currentTimeNanos + maxDelay.lengthNanos);
}
http://git-wip-us.apache.org/repos/asf/storm/blob/fe16fd40/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryService.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryService.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryService.java
index bf17a5a..f0230c3 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryService.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryService.java
@@ -22,6 +22,7 @@ import org.apache.kafka.common.TopicPartition;
import java.io.Serializable;
import java.util.Collection;
+import java.util.Map;
import java.util.Set;
/**
@@ -54,10 +55,11 @@ public interface KafkaSpoutRetryService extends Serializable {
boolean retainAll(Collection<TopicPartition> topicPartitions);
/**
- * @return set of topic partitions that have offsets that are ready to be retried, i.e.,
- * for which a tuple has failed and has retry time less than current time
+ * @return The earliest retriable offset for each TopicPartition that has
+ * offsets ready to be retried, i.e. for which a tuple has failed
+ * and has retry time less than current time
*/
- Set<TopicPartition> retriableTopicPartitions();
+ Map<TopicPartition, Long> earliestRetriableOffsets();
/**
* Checks if a specific failed {@link KafkaSpoutMessageId} is ready to be retried,
@@ -75,4 +77,6 @@ public interface KafkaSpoutRetryService extends Serializable {
* Returns false is this message is not scheduled for retrial
*/
boolean isScheduled(KafkaSpoutMessageId msgId);
+
+ int readyMessageCount();
}
http://git-wip-us.apache.org/repos/asf/storm/blob/fe16fd40/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutEmitTest.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutEmitTest.java b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutEmitTest.java
new file mode 100755
index 0000000..447f8c4
--- /dev/null
+++ b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutEmitTest.java
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2017 The Apache Software Foundation.
+ *
+ * Licensed 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.storm.kafka.spout;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.anyCollection;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.kafka.clients.consumer.ConsumerRebalanceListener;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.apache.kafka.clients.consumer.ConsumerRecords;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.storm.kafka.spout.builders.SingleTopicKafkaSpoutConfiguration;
+import org.apache.storm.kafka.spout.internal.KafkaConsumerFactory;
+import org.apache.storm.spout.SpoutOutputCollector;
+import org.apache.storm.task.TopologyContext;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import static org.apache.storm.kafka.spout.builders.SingleTopicKafkaSpoutConfiguration.getKafkaSpoutConfigBuilder;
+import static org.mockito.Matchers.anyList;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.never;
+
+import java.util.HashSet;
+import org.apache.storm.utils.Time;
+import org.apache.storm.utils.Time.SimulatedTime;
+import org.mockito.InOrder;
+
+public class KafkaSpoutEmitTest {
+
+ private final long offsetCommitPeriodMs = 2_000;
+ private final TopologyContext contextMock = mock(TopologyContext.class);
+ private final SpoutOutputCollector collectorMock = mock(SpoutOutputCollector.class);
+ private final Map<String, Object> conf = new HashMap<>();
+ private final TopicPartition partition = new TopicPartition(SingleTopicKafkaSpoutConfiguration.TOPIC, 1);
+ private KafkaConsumer<String, String> consumerMock;
+ private KafkaSpout<String, String> spout;
+ private KafkaSpoutConfig spoutConfig;
+
+ private void setupSpout(Set<TopicPartition> assignedPartitions) {
+ spoutConfig = getKafkaSpoutConfigBuilder(-1)
+ .setOffsetCommitPeriodMs(offsetCommitPeriodMs)
+ .build();
+
+ consumerMock = mock(KafkaConsumer.class);
+ KafkaConsumerFactory<String, String> consumerFactory = new KafkaConsumerFactory<String, String>() {
+ @Override
+ public KafkaConsumer<String, String> createConsumer(KafkaSpoutConfig<String, String> kafkaSpoutConfig) {
+ return consumerMock;
+ }
+ };
+
+ //Set up a spout listening to 1 topic partition
+ spout = new KafkaSpout<>(spoutConfig, consumerFactory);
+
+ spout.open(conf, contextMock, collectorMock);
+ spout.activate();
+
+ ArgumentCaptor<ConsumerRebalanceListener> rebalanceListenerCapture = ArgumentCaptor.forClass(ConsumerRebalanceListener.class);
+ verify(consumerMock).subscribe(anyCollection(), rebalanceListenerCapture.capture());
+
+ //Assign partitions to the spout
+ ConsumerRebalanceListener consumerRebalanceListener = rebalanceListenerCapture.getValue();
+ consumerRebalanceListener.onPartitionsAssigned(assignedPartitions);
+ }
+
+ @Test
+ public void testNextTupleEmitsAtMostOneTuple() {
+ //The spout should emit at most one message per call to nextTuple
+ //This is necessary for Storm to be able to throttle the spout according to maxSpoutPending
+ setupSpout(Collections.singleton(partition));
+ Map<TopicPartition, List<ConsumerRecord<String, String>>> records = new HashMap<>();
+ List<ConsumerRecord<String, String>> recordsForPartition = new ArrayList<>();
+ for (int i = 0; i < 10; i++) {
+ recordsForPartition.add(new ConsumerRecord(partition.topic(), partition.partition(), i, "key", "value"));
+ }
+ records.put(partition, recordsForPartition);
+
+ when(consumerMock.poll(anyLong()))
+ .thenReturn(new ConsumerRecords(records));
+
+ spout.nextTuple();
+
+ verify(collectorMock, times(1)).emit(anyString(), anyList(), anyObject());
+ }
+
+ @Test
+ public void testNextTupleEmitsFailedMessagesEvenWhenMaxUncommittedOffsetsIsExceeded() {
+ //The spout must reemit failed messages waiting for retry even if it is not allowed to poll for new messages due to maxUncommittedOffsets being exceeded
+
+ //Emit maxUncommittedOffsets messages, and fail all of them. Then ensure that the spout will retry them when the retry backoff has passed
+ try (SimulatedTime simulatedTime = new SimulatedTime()) {
+ setupSpout(Collections.singleton(partition));
+ Map<TopicPartition, List<ConsumerRecord<String, String>>> records = new HashMap<>();
+ List<ConsumerRecord<String, String>> recordsForPartition = new ArrayList<>();
+ for (int i = 0; i < spoutConfig.getMaxUncommittedOffsets(); i++) {
+ //This is cheating a bit since maxPollRecords would normally spread this across multiple polls
+ recordsForPartition.add(new ConsumerRecord(partition.topic(), partition.partition(), i, "key", "value"));
+ }
+ records.put(partition, recordsForPartition);
+
+ when(consumerMock.poll(anyLong()))
+ .thenReturn(new ConsumerRecords(records));
+
+ for (int i = 0; i < recordsForPartition.size(); i++) {
+ spout.nextTuple();
+ }
+
+ ArgumentCaptor<KafkaSpoutMessageId> messageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
+ verify(collectorMock, times(recordsForPartition.size())).emit(anyString(), anyList(), messageIds.capture());
+
+ for (KafkaSpoutMessageId messageId : messageIds.getAllValues()) {
+ spout.fail(messageId);
+ }
+
+ reset(collectorMock);
+
+ Time.advanceTime(50);
+ //No backoff for test retry service, just check that messages will retry immediately
+ for (int i = 0; i < recordsForPartition.size(); i++) {
+ spout.nextTuple();
+ }
+
+ ArgumentCaptor<KafkaSpoutMessageId> retryMessageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
+ verify(collectorMock, times(recordsForPartition.size())).emit(anyString(), anyList(), retryMessageIds.capture());
+
+ //Verify that the poll started at the earliest retriable tuple offset
+ List<Long> failedOffsets = new ArrayList<>();
+ for(KafkaSpoutMessageId msgId : messageIds.getAllValues()) {
+ failedOffsets.add(msgId.offset());
+ }
+ InOrder inOrder = inOrder(consumerMock);
+ inOrder.verify(consumerMock).seek(partition, failedOffsets.get(0));
+ inOrder.verify(consumerMock).poll(anyLong());
+ }
+ }
+
+ @Test
+ public void testNextTupleEmitsAtMostMaxUncommittedOffsetsPlusMaxPollRecordsWhenRetryingTuples() {
+ /*
+ The spout must reemit failed messages waiting for retry even if it is not allowed to poll for new messages due to maxUncommittedOffsets being exceeded.
+ numUncommittedOffsets is equal to numNonRetriableEmittedTuples + numRetriableTuples.
+ The spout will only emit if numUncommittedOffsets - numRetriableTuples < maxUncommittedOffsets (i.e. numNonRetriableEmittedTuples < maxUncommittedOffsets)
+ This means that the latest offset a poll can start at for a retriable partition,
+ counting from the last committed offset, is maxUncommittedOffsets,
+ where there are maxUncommittedOffsets - 1 uncommitted tuples "to the left".
+ If the retry poll starts at that offset, it at most emits the retried tuple plus maxPollRecords - 1 new tuples.
+ The limit on uncommitted offsets for one partition is therefore maxUncommittedOffsets + maxPollRecords - 1.
+
+ It is only necessary to test this for a single partition, because partitions can't contribute negatively to numNonRetriableEmittedTuples,
+ so if the limit holds for one partition, it will also hold for each individual partition when multiple are involved.
+
+ This makes the actual limit numPartitions * (maxUncommittedOffsets + maxPollRecords - 1)
+ */
+
+ //Emit maxUncommittedOffsets messages, and fail only the last. Then ensure that the spout will allow no more than maxUncommittedOffsets + maxPollRecords - 1 uncommitted offsets when retrying
+ try (SimulatedTime simulatedTime = new SimulatedTime()) {
+ setupSpout(Collections.singleton(partition));
+
+ Map<TopicPartition, List<ConsumerRecord<String, String>>> firstPollRecords = new HashMap<>();
+ List<ConsumerRecord<String, String>> firstPollRecordsForPartition = new ArrayList<>();
+ for (int i = 0; i < spoutConfig.getMaxUncommittedOffsets(); i++) {
+ //This is cheating a bit since maxPollRecords would normally spread this across multiple polls
+ firstPollRecordsForPartition.add(new ConsumerRecord(partition.topic(), partition.partition(), i, "key", "value"));
+ }
+ firstPollRecords.put(partition, firstPollRecordsForPartition);
+
+ int maxPollRecords = 5;
+ Map<TopicPartition, List<ConsumerRecord<String, String>>> secondPollRecords = new HashMap<>();
+ List<ConsumerRecord<String, String>> secondPollRecordsForPartition = new ArrayList<>();
+ for(int i = 0; i < maxPollRecords; i++) {
+ secondPollRecordsForPartition.add(new ConsumerRecord(partition.topic(), partition.partition(), spoutConfig.getMaxUncommittedOffsets() + i, "key", "value"));
+ }
+ secondPollRecords.put(partition, secondPollRecordsForPartition);
+
+ when(consumerMock.poll(anyLong()))
+ .thenReturn(new ConsumerRecords(firstPollRecords))
+ .thenReturn(new ConsumerRecords(secondPollRecords));
+
+ for (int i = 0; i < spoutConfig.getMaxUncommittedOffsets() + maxPollRecords; i++) {
+ spout.nextTuple();
+ }
+
+ ArgumentCaptor<KafkaSpoutMessageId> messageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
+ verify(collectorMock, times(firstPollRecordsForPartition.size())).emit(anyString(), anyList(), messageIds.capture());
+
+ KafkaSpoutMessageId failedMessageId = messageIds.getAllValues().get(messageIds.getAllValues().size() - 1);
+ spout.fail(failedMessageId);
+
+ reset(collectorMock);
+
+ //Now make the single failed tuple retriable
+ Time.advanceTime(50);
+ //The spout should allow another poll since there are now only maxUncommittedOffsets - 1 nonretriable tuples
+ for (int i = 0; i < firstPollRecordsForPartition.size() + maxPollRecords; i++) {
+ spout.nextTuple();
+ }
+
+ ArgumentCaptor<KafkaSpoutMessageId> retryBatchMessageIdsCaptor = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
+ verify(collectorMock, times(maxPollRecords)).emit(anyString(), anyList(), retryBatchMessageIdsCaptor.capture());
+ reset(collectorMock);
+
+ //Check that the consumer started polling at the failed tuple offset
+ InOrder inOrder = inOrder(consumerMock);
+ inOrder.verify(consumerMock).seek(partition, failedMessageId.offset());
+ inOrder.verify(consumerMock).poll(anyLong());
+
+ //Now fail all except one of the last batch, and check that the spout won't reemit any tuples because there are more than maxUncommittedOffsets nonretriable tuples
+ Time.advanceTime(50);
+ List<KafkaSpoutMessageId> retryBatchMessageIds = retryBatchMessageIdsCaptor.getAllValues();
+ KafkaSpoutMessageId firstTupleFromRetryBatch = retryBatchMessageIds.remove(0);
+ for(KafkaSpoutMessageId msgId : retryBatchMessageIds) {
+ spout.fail(msgId);
+ }
+ for (int i = 0; i < firstPollRecordsForPartition.size() + maxPollRecords; i++) {
+ spout.nextTuple();
+ }
+ verify(collectorMock, never()).emit(anyString(), anyList(), anyObject());
+
+ //Fail the last tuple, which brings the number of nonretriable tuples back under the limit, and check that the spout polls again
+ spout.fail(firstTupleFromRetryBatch);
+ spout.nextTuple();
+ verify(collectorMock, times(1)).emit(anyString(), anyList(), anyObject());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/storm/blob/fe16fd40/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutRebalanceTest.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutRebalanceTest.java b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutRebalanceTest.java
index 6a0a63e..81e3807 100644
--- a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutRebalanceTest.java
+++ b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutRebalanceTest.java
@@ -15,7 +15,7 @@
*/
package org.apache.storm.kafka.spout;
-import static org.apache.storm.kafka.spout.builders.SingleTopicKafkaSpoutConfiguration.getKafkaSpoutConfig;
+import static org.apache.storm.kafka.spout.builders.SingleTopicKafkaSpoutConfiguration.getKafkaSpoutConfigBuilder;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.hasKey;
import static org.junit.Assert.assertThat;
@@ -126,7 +126,9 @@ public class KafkaSpoutRebalanceTest {
public void spoutMustIgnoreAcksForTuplesItIsNotAssignedAfterRebalance() throws Exception {
//Acking tuples for partitions that are no longer assigned is useless since the spout will not be allowed to commit them
try (SimulatedTime simulatedTime = new SimulatedTime()) {
- KafkaSpout<String, String> spout = new KafkaSpout<>(getKafkaSpoutConfig(-1, this.offsetCommitPeriodMs), consumerFactoryMock);
+ KafkaSpout<String, String> spout = new KafkaSpout<>(getKafkaSpoutConfigBuilder(-1)
+ .setOffsetCommitPeriodMs(offsetCommitPeriodMs)
+ .build(), consumerFactoryMock);
String topic = SingleTopicKafkaSpoutConfiguration.TOPIC;
TopicPartition partitionThatWillBeRevoked = new TopicPartition(topic, 1);
TopicPartition assignedPartition = new TopicPartition(topic, 2);
@@ -155,7 +157,10 @@ public class KafkaSpoutRebalanceTest {
public void spoutMustIgnoreFailsForTuplesItIsNotAssignedAfterRebalance() throws Exception {
//Failing tuples for partitions that are no longer assigned is useless since the spout will not be allowed to commit them if they later pass
KafkaSpoutRetryService retryServiceMock = mock(KafkaSpoutRetryService.class);
- KafkaSpout<String, String> spout = new KafkaSpout<>(getKafkaSpoutConfig(-1, 10, retryServiceMock), consumerFactoryMock);
+ KafkaSpout<String, String> spout = new KafkaSpout<>(getKafkaSpoutConfigBuilder(-1)
+ .setOffsetCommitPeriodMs(10)
+ .setRetry(retryServiceMock)
+ .build(), consumerFactoryMock);
String topic = SingleTopicKafkaSpoutConfiguration.TOPIC;
TopicPartition partitionThatWillBeRevoked = new TopicPartition(topic, 1);
TopicPartition assignedPartition = new TopicPartition(topic, 2);
http://git-wip-us.apache.org/repos/asf/storm/blob/fe16fd40/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/MaxUncommittedOffsetTest.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/MaxUncommittedOffsetTest.java b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/MaxUncommittedOffsetTest.java
new file mode 100755
index 0000000..a7ad4c2
--- /dev/null
+++ b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/MaxUncommittedOffsetTest.java
@@ -0,0 +1,245 @@
+/*
+ * Copyright 2017 The Apache Software Foundation.
+ *
+ * Licensed 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.storm.kafka.spout;
+
+import static org.apache.storm.kafka.spout.builders.SingleTopicKafkaSpoutConfiguration.getKafkaSpoutConfigBuilder;
+import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.isIn;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.anyList;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.storm.kafka.KafkaUnitRule;
+import org.apache.storm.kafka.spout.builders.SingleTopicKafkaSpoutConfiguration;
+import org.apache.storm.spout.SpoutOutputCollector;
+import org.apache.storm.task.TopologyContext;
+import org.apache.storm.utils.Time;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.MockitoAnnotations;
+
+public class MaxUncommittedOffsetTest {
+
+ @Rule
+ public KafkaUnitRule kafkaUnitRule = new KafkaUnitRule();
+
+ private final TopologyContext topologyContext = mock(TopologyContext.class);
+ private final Map<String, Object> conf = new HashMap<>();
+ private final SpoutOutputCollector collector = mock(SpoutOutputCollector.class);
+ private final long commitOffsetPeriodMs = 2_000;
+ private final int numMessages = 100;
+ private final int maxUncommittedOffsets = 10;
+ private final int maxPollRecords = 5;
+ private final int initialRetryDelaySecs = 60;
+ private final KafkaSpoutConfig spoutConfig = getKafkaSpoutConfigBuilder(kafkaUnitRule.getKafkaUnit().getKafkaPort())
+ .setOffsetCommitPeriodMs(commitOffsetPeriodMs)
+ .setMaxPollRecords(maxPollRecords)
+ .setMaxUncommittedOffsets(maxUncommittedOffsets)
+ .setRetry(new KafkaSpoutRetryExponentialBackoff(KafkaSpoutRetryExponentialBackoff.TimeInterval.seconds(initialRetryDelaySecs), KafkaSpoutRetryExponentialBackoff.TimeInterval.seconds(0),
+ 1, KafkaSpoutRetryExponentialBackoff.TimeInterval.seconds(initialRetryDelaySecs))) //Retry once after a minute
+ .build();
+ private KafkaSpout<String, String> spout;
+
+ @Before
+ public void setUp() {
+ //This is because the tests are checking that a hard cap of maxUncommittedOffsets + maxPollRecords - 1 uncommitted offsets exists
+ //so Kafka must be able to return more messages than that in order for the tests to be meaningful
+ assertThat("Current tests require numMessages >= 2*maxUncommittedOffsets", numMessages, greaterThanOrEqualTo(maxUncommittedOffsets * 2));
+ //This is to verify that a low maxPollRecords does not interfere with reemitting failed tuples
+ //The spout must be able to reemit all retriable tuples, even if the maxPollRecords is set to a low value compared to maxUncommittedOffsets.
+ assertThat("Current tests require maxPollRecords < maxUncommittedOffsets", maxPollRecords, lessThanOrEqualTo(maxUncommittedOffsets));
+ MockitoAnnotations.initMocks(this);
+ this.spout = new KafkaSpout<>(spoutConfig);
+ }
+
+ private void populateTopicData(String topicName, int msgCount) throws Exception {
+ kafkaUnitRule.getKafkaUnit().createTopic(topicName);
+
+ for (int i = 0; i < msgCount; i++) {
+ ProducerRecord<String, String> producerRecord = new ProducerRecord<>(
+ topicName, Integer.toString(i),
+ Integer.toString(i));
+
+ kafkaUnitRule.getKafkaUnit().sendMessage(producerRecord);
+ }
+ }
+
+ private void initializeSpout(int msgCount) throws Exception {
+ populateTopicData(SingleTopicKafkaSpoutConfiguration.TOPIC, msgCount);
+ spout.open(conf, topologyContext, collector);
+ spout.activate();
+ }
+
+ private ArgumentCaptor<KafkaSpoutMessageId> emitMaxUncommittedOffsetsMessagesAndCheckNoMoreAreEmitted(int messageCount) throws Exception {
+ assertThat("The message count is less than maxUncommittedOffsets. This test is not meaningful with this configuration.", messageCount, greaterThanOrEqualTo(maxUncommittedOffsets));
+ //The spout must respect maxUncommittedOffsets when requesting/emitting tuples
+ initializeSpout(messageCount);
+
+ //Try to emit all messages. Ensure only maxUncommittedOffsets are emitted
+ ArgumentCaptor<KafkaSpoutMessageId> messageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
+ for (int i = 0; i < messageCount; i++) {
+ spout.nextTuple();
+ };
+ verify(collector, times(maxUncommittedOffsets)).emit(
+ anyString(),
+ anyList(),
+ messageIds.capture());
+ return messageIds;
+ }
+
+ @Test
+ public void testNextTupleCanEmitMoreMessagesWhenDroppingBelowMaxUncommittedOffsetsDueToCommit() throws Exception {
+ //The spout must respect maxUncommittedOffsets after committing a set of records
+ try (Time.SimulatedTime simulatedTime = new Time.SimulatedTime()) {
+ //First check that maxUncommittedOffsets is respected when emitting from scratch
+ ArgumentCaptor<KafkaSpoutMessageId> messageIds = emitMaxUncommittedOffsetsMessagesAndCheckNoMoreAreEmitted(numMessages);
+ reset(collector);
+
+ //Ack all emitted messages and commit them
+ for (KafkaSpoutMessageId messageId : messageIds.getAllValues()) {
+ spout.ack(messageId);
+ }
+ Time.advanceTime(commitOffsetPeriodMs + KafkaSpout.TIMER_DELAY_MS);
+ spout.nextTuple();
+
+ //Now check that the spout will emit another maxUncommittedOffsets messages
+ for (int i = 0; i < numMessages; i++) {
+ spout.nextTuple();
+ }
+ verify(collector, times(maxUncommittedOffsets)).emit(
+ anyString(),
+ anyList(),
+ anyObject());
+ }
+ }
+
+ @Test
+ public void testNextTupleWillRespectMaxUncommittedOffsetsWhenThereAreAckedUncommittedTuples() throws Exception {
+ //The spout must respect maxUncommittedOffsets even if some tuples have been acked but not committed
+ try (Time.SimulatedTime simulatedTime = new Time.SimulatedTime()) {
+ //First check that maxUncommittedOffsets is respected when emitting from scratch
+ ArgumentCaptor<KafkaSpoutMessageId> messageIds = emitMaxUncommittedOffsetsMessagesAndCheckNoMoreAreEmitted(numMessages);
+ reset(collector);
+
+ //Fail all emitted messages except the last one. Try to commit.
+ List<KafkaSpoutMessageId> messageIdList = messageIds.getAllValues();
+ for (int i = 0; i < messageIdList.size() - 1; i++) {
+ spout.fail(messageIdList.get(i));
+ }
+ spout.ack(messageIdList.get(messageIdList.size() - 1));
+ Time.advanceTime(commitOffsetPeriodMs + KafkaSpout.TIMER_DELAY_MS);
+ spout.nextTuple();
+
+ //Now check that the spout will not emit anything else since nothing has been committed
+ for (int i = 0; i < numMessages; i++) {
+ spout.nextTuple();
+ }
+
+ verify(collector, times(0)).emit(
+ anyString(),
+ anyList(),
+ anyObject());
+ }
+ }
+
+ private void failAllExceptTheFirstMessageThenCommit(ArgumentCaptor<KafkaSpoutMessageId> messageIds) {
+ //Fail all emitted messages except the first. Commit the first.
+ List<KafkaSpoutMessageId> messageIdList = messageIds.getAllValues();
+ for (int i = 1; i < messageIdList.size(); i++) {
+ spout.fail(messageIdList.get(i));
+ }
+ spout.ack(messageIdList.get(0));
+ Time.advanceTime(commitOffsetPeriodMs + KafkaSpout.TIMER_DELAY_MS);
+ spout.nextTuple();
+ }
+
+ @Test
+ public void testNextTupleWillNotEmitMoreThanMaxUncommittedOffsetsPlusMaxPollRecordsMessages() throws Exception {
+ //The upper bound on uncommitted offsets should be maxUncommittedOffsets + maxPollRecords - 1
+ //This is reachable by emitting maxUncommittedOffsets messages, acking the first message, then polling.
+ try (Time.SimulatedTime simulatedTime = new Time.SimulatedTime()) {
+ //First check that maxUncommittedOffsets is respected when emitting from scratch
+ ArgumentCaptor<KafkaSpoutMessageId> messageIds = emitMaxUncommittedOffsetsMessagesAndCheckNoMoreAreEmitted(numMessages);
+ reset(collector);
+
+ failAllExceptTheFirstMessageThenCommit(messageIds);
+
+ //Offset 0 is acked, 1 to maxUncommittedOffsets - 1 are failed
+ //The spout should now emit another maxPollRecords messages
+ //This is allowed because the acked message brings the numUncommittedOffsets below the cap
+ for (int i = 0; i < maxUncommittedOffsets; i++) {
+ spout.nextTuple();
+ }
+
+ ArgumentCaptor<KafkaSpoutMessageId> secondRunMessageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
+ verify(collector, times(maxPollRecords)).emit(
+ anyString(),
+ anyList(),
+ secondRunMessageIds.capture());
+ reset(collector);
+
+ List<Long> firstRunOffsets = new ArrayList<>();
+ for (KafkaSpoutMessageId msgId : messageIds.getAllValues()) {
+ firstRunOffsets.add(msgId.offset());
+ }
+ List<Long> secondRunOffsets = new ArrayList<>();
+ for (KafkaSpoutMessageId msgId : secondRunMessageIds.getAllValues()) {
+ secondRunOffsets.add(msgId.offset());
+ }
+ assertThat("Expected the newly emitted messages to have no overlap with the first batch", secondRunOffsets.removeAll(firstRunOffsets), is(false));
+
+ //Offset 0 is acked, 1 to maxUncommittedOffsets-1 are failed, maxUncommittedOffsets to maxUncommittedOffsets + maxPollRecords-1 are emitted
+ //There are now maxUncommittedOffsets-1 + maxPollRecords records emitted past the last committed offset
+ //Advance time so the failed tuples become ready for retry, and check that the spout will emit retriable tuples as long as numNonRetriableEmittedTuples < maxUncommittedOffsets
+
+ int numNonRetriableEmittedTuples = maxPollRecords; //The other tuples were failed and are becoming retriable
+ int allowedPolls = (int)Math.ceil((maxUncommittedOffsets - numNonRetriableEmittedTuples)/(double)maxPollRecords);
+ Time.advanceTimeSecs(initialRetryDelaySecs);
+ for (int i = 0; i < numMessages; i++) {
+ spout.nextTuple();
+ }
+ ArgumentCaptor<KafkaSpoutMessageId> thirdRunMessageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
+ verify(collector, times(allowedPolls*maxPollRecords)).emit(
+ anyString(),
+ anyList(),
+ thirdRunMessageIds.capture());
+ reset(collector);
+
+ List<Long> thirdRunOffsets = new ArrayList<>();
+ for (KafkaSpoutMessageId msgId : thirdRunMessageIds.getAllValues()) {
+ thirdRunOffsets.add(msgId.offset());
+ }
+
+ assertThat("Expected the emitted messages to be retries of the failed tuples from the first batch", thirdRunOffsets, everyItem(isIn(firstRunOffsets)));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/storm/blob/fe16fd40/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/SingleTopicKafkaSpoutTest.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/SingleTopicKafkaSpoutTest.java b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/SingleTopicKafkaSpoutTest.java
index 1121642..884709d 100644
--- a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/SingleTopicKafkaSpoutTest.java
+++ b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/SingleTopicKafkaSpoutTest.java
@@ -17,7 +17,8 @@
*/
package org.apache.storm.kafka.spout;
-import static org.apache.storm.kafka.spout.builders.SingleTopicKafkaSpoutConfiguration.getKafkaSpoutConfig;
+
+import static org.apache.storm.kafka.spout.builders.SingleTopicKafkaSpoutConfiguration.getKafkaSpoutConfigBuilder;
import org.apache.kafka.clients.consumer.OffsetAndMetadata;
import org.apache.kafka.clients.producer.ProducerRecord;
@@ -37,6 +38,7 @@ import java.util.concurrent.TimeoutException;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Matchers.anyList;
+import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -46,6 +48,9 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.TopicPartition;
import org.apache.storm.kafka.spout.internal.KafkaConsumerFactory;
@@ -76,7 +81,9 @@ public class SingleTopicKafkaSpoutTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- KafkaSpoutConfig spoutConfig = getKafkaSpoutConfig(kafkaUnitRule.getKafkaUnit().getKafkaPort(), commitOffsetPeriodMs);
+ KafkaSpoutConfig spoutConfig = getKafkaSpoutConfigBuilder(kafkaUnitRule.getKafkaUnit().getKafkaPort())
+ .setOffsetCommitPeriodMs(commitOffsetPeriodMs)
+ .build();
this.consumerSpy = spy(new KafkaConsumerFactoryDefault().createConsumer(spoutConfig));
this.consumerFactory = new KafkaConsumerFactory<String, String>() {
@Override
@@ -275,4 +282,38 @@ public class SingleTopicKafkaSpoutTest {
verifyAllMessagesCommitted(messageCount);
}
}
+
+ @Test
+ public void shouldReplayAllFailedTuplesWhenFailedOutOfOrder() throws Exception {
+ //The spout must reemit retriable tuples, even if they fail out of order.
+ //The spout should be able to skip tuples it has already emitted when retrying messages, even if those tuples are also retries.
+ int messageCount = 10;
+ initializeSpout(messageCount);
+
+ //play all tuples
+ for (int i = 0; i < messageCount; i++) {
+ spout.nextTuple();
+ }
+ ArgumentCaptor<KafkaSpoutMessageId> messageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
+ verify(collector, times(messageCount)).emit(anyString(), anyList(), messageIds.capture());
+ reset(collector);
+ //Fail tuple 5 and 3, call nextTuple, then fail tuple 2
+ List<KafkaSpoutMessageId> capturedMessageIds = messageIds.getAllValues();
+ spout.fail(capturedMessageIds.get(5));
+ spout.fail(capturedMessageIds.get(3));
+ spout.nextTuple();
+ spout.fail(capturedMessageIds.get(2));
+
+ //Check that the spout will reemit all 3 failed tuples and no other tuples
+ ArgumentCaptor<KafkaSpoutMessageId> reemittedMessageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
+ for (int i = 0; i < messageCount; i++) {
+ spout.nextTuple();
+ }
+ verify(collector, times(3)).emit(anyString(), anyList(), reemittedMessageIds.capture());
+ Set<KafkaSpoutMessageId> expectedReemitIds = new HashSet<>();
+ expectedReemitIds.add(capturedMessageIds.get(5));
+ expectedReemitIds.add(capturedMessageIds.get(3));
+ expectedReemitIds.add(capturedMessageIds.get(2));
+ assertThat("Expected reemits to be the 3 failed tuples", new HashSet<>(reemittedMessageIds.getAllValues()), is(expectedReemitIds));
+ }
}
http://git-wip-us.apache.org/repos/asf/storm/blob/fe16fd40/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/builders/SingleTopicKafkaSpoutConfiguration.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/builders/SingleTopicKafkaSpoutConfiguration.java b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/builders/SingleTopicKafkaSpoutConfiguration.java
index 99bd3de..d5c052b 100644
--- a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/builders/SingleTopicKafkaSpoutConfiguration.java
+++ b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/builders/SingleTopicKafkaSpoutConfiguration.java
@@ -46,19 +46,11 @@ public class SingleTopicKafkaSpoutConfiguration {
public static StormTopology getTopologyKafkaSpout(int port) {
final TopologyBuilder tp = new TopologyBuilder();
- tp.setSpout("kafka_spout", new KafkaSpout<>(getKafkaSpoutConfig(port)), 1);
+ tp.setSpout("kafka_spout", new KafkaSpout<>(getKafkaSpoutConfigBuilder(port).build()), 1);
tp.setBolt("kafka_bolt", new KafkaSpoutTestBolt()).shuffleGrouping("kafka_spout", STREAM);
return tp.createTopology();
}
- static public KafkaSpoutConfig<String, String> getKafkaSpoutConfig(int port) {
- return getKafkaSpoutConfig(port, 10_000);
- }
-
- static public KafkaSpoutConfig<String, String> getKafkaSpoutConfig(int port, long offsetCommitPeriodMs) {
- return getKafkaSpoutConfig(port, offsetCommitPeriodMs, getRetryService());
- }
-
private static Func<ConsumerRecord<String, String>, List<Object>> TOPIC_KEY_VALUE_FUNC = new Func<ConsumerRecord<String, String>, List<Object>>() {
@Override
public List<Object> apply(ConsumerRecord<String, String> r) {
@@ -66,18 +58,17 @@ public class SingleTopicKafkaSpoutConfiguration {
}
};
- static public KafkaSpoutConfig<String,String> getKafkaSpoutConfig(int port, long offsetCommitPeriodMs, KafkaSpoutRetryService retryService) {
+ public static KafkaSpoutConfig.Builder<String,String> getKafkaSpoutConfigBuilder(int port) {
return KafkaSpoutConfig.builder("127.0.0.1:" + port, TOPIC)
.setRecordTranslator(TOPIC_KEY_VALUE_FUNC,
new Fields("topic", "key", "value"), STREAM)
.setGroupId("kafkaSpoutTestGroup")
.setMaxPollRecords(5)
- .setRetry(retryService)
- .setOffsetCommitPeriodMs(offsetCommitPeriodMs)
+ .setRetry(getRetryService())
+ .setOffsetCommitPeriodMs(10_000)
.setFirstPollOffsetStrategy(EARLIEST)
.setMaxUncommittedOffsets(250)
- .setPollTimeoutMs(1000)
- .build();
+ .setPollTimeoutMs(1000);
}
protected static KafkaSpoutRetryService getRetryService() {
[05/40] storm git commit: Merge branch 'STORM-2450' of
https://github.com/revans2/incubator-storm into STORM-2450
Posted by ka...@apache.org.
Merge branch 'STORM-2450' of https://github.com/revans2/incubator-storm into STORM-2450
STORM-2450: Write resources into correct local directory
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/bb126aeb
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/bb126aeb
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/bb126aeb
Branch: refs/heads/1.1.x-branch
Commit: bb126aeb89459b80e5154bccda543a164a3e4931
Parents: 3a59ee9
Author: Robert Evans <ev...@yahoo-inc.com>
Authored: Mon Apr 3 10:49:25 2017 -0500
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:24:38 2017 +0900
----------------------------------------------------------------------
.../src/jvm/org/apache/storm/localizer/AsyncLocalizer.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/bb126aeb/storm-core/src/jvm/org/apache/storm/localizer/AsyncLocalizer.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/localizer/AsyncLocalizer.java b/storm-core/src/jvm/org/apache/storm/localizer/AsyncLocalizer.java
index a2f9857..ae5103f 100644
--- a/storm-core/src/jvm/org/apache/storm/localizer/AsyncLocalizer.java
+++ b/storm-core/src/jvm/org/apache/storm/localizer/AsyncLocalizer.java
@@ -191,18 +191,18 @@ public class AsyncLocalizer implements ILocalizer, Shutdownable {
String resourcesJar = AsyncLocalizer.resourcesJar();
URL url = classloader.getResource(ConfigUtils.RESOURCES_SUBDIR);
- String targetDir = tmproot + Utils.FILE_PATH_SEPARATOR + ConfigUtils.RESOURCES_SUBDIR;
+ String targetDir = tmproot + Utils.FILE_PATH_SEPARATOR;
if (resourcesJar != null) {
LOG.info("Extracting resources from jar at {} to {}", resourcesJar, targetDir);
Utils.extractDirFromJar(resourcesJar, ConfigUtils.RESOURCES_SUBDIR, new File(targetDir));
} else if (url != null) {
- LOG.info("Copying resources at {} to {} ", url.toString(), targetDir);
+ LOG.info("Copying resources at {} to {}", url, targetDir);
if ("jar".equals(url.getProtocol())) {
JarURLConnection urlConnection = (JarURLConnection) url.openConnection();
Utils.extractDirFromJar(urlConnection.getJarFileURL().getFile(), ConfigUtils.RESOURCES_SUBDIR, new File(targetDir));
} else {
- _fsOps.copyDirectory(new File(url.getFile()), new File(targetDir));
+ _fsOps.copyDirectory(new File(url.getFile()), new File(targetDir, ConfigUtils.RESOURCES_SUBDIR));
}
}
}
[07/40] storm git commit: Properly validate supervisor.scheduler.meta
Posted by ka...@apache.org.
Properly validate supervisor.scheduler.meta
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/bdeadfb8
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/bdeadfb8
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/bdeadfb8
Branch: refs/heads/1.1.x-branch
Commit: bdeadfb8333c2b778d6a371c15f5cf1a6ef960eb
Parents: 2cf1a3c
Author: David Judd <dj...@stripe.com>
Authored: Tue Mar 21 16:02:01 2017 -0700
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:26:30 2017 +0900
----------------------------------------------------------------------
storm-core/src/jvm/org/apache/storm/Config.java | 20 +++++++++---------
.../org/apache/storm/TestConfigValidate.java | 22 +++++++++++++++++++-
2 files changed, 31 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/bdeadfb8/storm-core/src/jvm/org/apache/storm/Config.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/Config.java b/storm-core/src/jvm/org/apache/storm/Config.java
index e552a09..43df951 100644
--- a/storm-core/src/jvm/org/apache/storm/Config.java
+++ b/storm-core/src/jvm/org/apache/storm/Config.java
@@ -951,7 +951,7 @@ public class Config extends HashMap<String, Object> {
@Deprecated
@isString
public static final String PACEMAKER_HOST = "pacemaker.host";
-
+
/**
* The port Pacemaker should run on. Clients should
* connect to this port to submit or read heartbeats.
@@ -1178,7 +1178,7 @@ public class Config extends HashMap<String, Object> {
/**
* the metadata configured on the supervisor
*/
- @isType(type=Map.class)
+ @isMapEntryType(keyType = String.class, valueType = String.class)
public static final String SUPERVISOR_SCHEDULER_META = "supervisor.scheduler.meta";
/**
@@ -1451,7 +1451,7 @@ public class Config extends HashMap<String, Object> {
/**
* The default heap memory size in MB per worker, used in the jvm -Xmx opts for launching the worker
- */
+ */
@isInteger
@isPositiveNumber
public static final String WORKER_HEAP_MEMORY_MB = "worker.heap.memory.mb";
@@ -1994,11 +1994,11 @@ public class Config extends HashMap<String, Object> {
@isInteger
public static final String TOPOLOGY_TICK_TUPLE_FREQ_SECS="topology.tick.tuple.freq.secs";
- /**
- * @deprecated this is no longer supported
- * Configure the wait strategy used for internal queuing. Can be used to tradeoff latency
- * vs. throughput
- */
+ /**
+ * @deprecated this is no longer supported
+ * Configure the wait strategy used for internal queuing. Can be used to tradeoff latency
+ * vs. throughput
+ */
@Deprecated
@isString
public static final String TOPOLOGY_DISRUPTOR_WAIT_STRATEGY="topology.disruptor.wait.strategy";
@@ -2284,7 +2284,7 @@ public class Config extends HashMap<String, Object> {
*/
@isInteger
public static final String STORM_WORKER_DISRUPTOR_FLUSHER_MAX_POOL_SIZE = "storm.worker.disruptor.flusher.max.pool.size";
-
+
public static void setClasspath(Map conf, String cp) {
conf.put(Config.TOPOLOGY_CLASSPATH, cp);
}
@@ -2497,4 +2497,4 @@ public class Config extends HashMap<String, Object> {
this.put(Config.TOPOLOGY_SCHEDULER_STRATEGY, clazz.getName());
}
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/storm/blob/bdeadfb8/storm-core/test/jvm/org/apache/storm/TestConfigValidate.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/TestConfigValidate.java b/storm-core/test/jvm/org/apache/storm/TestConfigValidate.java
index 0e08153..5b52c8d 100644
--- a/storm-core/test/jvm/org/apache/storm/TestConfigValidate.java
+++ b/storm-core/test/jvm/org/apache/storm/TestConfigValidate.java
@@ -59,7 +59,7 @@ public class TestConfigValidate {
conf.put(Config.PACEMAKER_AUTH_METHOD, "invalid");
ConfigValidation.validateFields(conf);
}
-
+
@Test
public void validConfigTest() throws InstantiationException, IllegalAccessException, NoSuchFieldException, NoSuchMethodException, InvocationTargetException {
@@ -150,6 +150,26 @@ public class TestConfigValidate {
}
@Test
+ public void testSupervisorSchedulerMetaIsStringMap() throws InvocationTargetException, NoSuchMethodException, NoSuchFieldException, InstantiationException, IllegalAccessException {
+ Map<String, Object> conf = new HashMap<String, Object>();
+ Map<String, Object> schedulerMeta = new HashMap<String, Object>();
+ conf.put(Config.SUPERVISOR_SCHEDULER_META, schedulerMeta);
+ ConfigValidation.validateFields(conf);
+
+ schedulerMeta.put("foo", "bar");
+
+ conf.put(Config.SUPERVISOR_SCHEDULER_META, schedulerMeta);
+ ConfigValidation.validateFields(conf);
+
+ schedulerMeta.put("baz", true);
+ try {
+ ConfigValidation.validateFields(conf);
+ Assert.fail("Expected Exception not Thrown");
+ } catch (IllegalArgumentException ex) {
+ }
+ }
+
+ @Test
public void testWorkerChildoptsIsStringOrStringList() throws InvocationTargetException, NoSuchMethodException, NoSuchFieldException, InstantiationException, IllegalAccessException {
Map<String, Object> conf = new HashMap<String, Object>();
Collection<Object> passCases = new LinkedList<Object>();
[12/40] storm git commit: Change emit order && change manual
partition order
Posted by ka...@apache.org.
Change emit order && change manual partition order
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/06932d60
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/06932d60
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/06932d60
Branch: refs/heads/1.1.x-branch
Commit: 06932d601d1d0727e4b56b63afbc37954940a859
Parents: 3971337
Author: liurenjie1024 <li...@gmail.com>
Authored: Mon Jan 23 17:34:37 2017 +0800
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:31:49 2017 +0900
----------------------------------------------------------------------
.../java/org/apache/storm/kafka/spout/KafkaSpout.java | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/06932d60/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
index 0bfcfea..47c305b 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
@@ -336,19 +336,18 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
collector.emit(tuple);
}
} else {
- if (tuple instanceof KafkaTuple) {
- collector.emit(((KafkaTuple) tuple).getStream(), tuple, msgId);
- } else {
- collector.emit(tuple, msgId);
- }
-
emitted.add(msgId);
-
if (isScheduled) { // Was scheduled for retry and re-emitted, so remove from schedule.
retryService.remove(msgId);
} else { //New tuple, hence increment the uncommitted offset counter
numUncommittedOffsets++;
}
+
+ if (tuple instanceof KafkaTuple) {
+ collector.emit(((KafkaTuple) tuple).getStream(), tuple, msgId);
+ } else {
+ collector.emit(tuple, msgId);
+ }
}
LOG.trace("Emitted tuple [{}] for record [{}] with msgId [{}]", tuple, record, msgId);
return true;
[02/40] storm git commit: STORM-2432: Storm-Kafka-Client Trident
Spout Seeks Incorrect Offset With UNCOMMITTED_LATEST Strategy
Posted by ka...@apache.org.
STORM-2432: Storm-Kafka-Client Trident Spout Seeks Incorrect Offset With UNCOMMITTED_LATEST Strategy
- Add check to execute first poll offset strategy only for the first poll rather than always
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/dc2d3219
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/dc2d3219
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/dc2d3219
Branch: refs/heads/1.1.x-branch
Commit: dc2d3219cc855e853723c12488f5a688e6268757
Parents: d6aac4c
Author: Hugo Louro <hm...@gmail.com>
Authored: Thu Mar 23 08:16:40 2017 -0700
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:21:54 2017 +0900
----------------------------------------------------------------------
.../kafka/spout/trident/KafkaTridentSpoutEmitter.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/dc2d3219/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/trident/KafkaTridentSpoutEmitter.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/trident/KafkaTridentSpoutEmitter.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/trident/KafkaTridentSpoutEmitter.java
index 8607853..87af0cf 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/trident/KafkaTridentSpoutEmitter.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/trident/KafkaTridentSpoutEmitter.java
@@ -61,6 +61,7 @@ public class KafkaTridentSpoutEmitter<K, V> implements IOpaquePartitionedTrident
// Bookkeeping
private final KafkaTridentSpoutManager<K, V> kafkaManager;
+ private Set<TopicPartition> firstPoll = new HashSet<>(); // set of topic-partitions for which first poll has already occurred
// Declare some KafkaTridentSpoutManager references for convenience
private final long pollTimeoutMs;
@@ -149,7 +150,7 @@ public class KafkaTridentSpoutEmitter<K, V> implements IOpaquePartitionedTrident
/**
* Determines the offset of the next fetch. For failed batches lastBatchMeta is not null and contains the fetch
- * offset of the failed batch. In this scenario the next fetch will take place at the offset of the failed batch.
+ * offset of the failed batch. In this scenario the next fetch will take place at offset of the failed batch + 1.
* When the previous batch is successful, lastBatchMeta is null, and the offset of the next fetch is either the
* offset of the last commit to kafka, or if no commit was yet made, the offset dictated by
* {@link KafkaSpoutConfig.FirstPollOffsetStrategy}
@@ -159,9 +160,10 @@ public class KafkaTridentSpoutEmitter<K, V> implements IOpaquePartitionedTrident
private long seek(TopicPartition tp, KafkaTridentSpoutBatchMetadata<K, V> lastBatchMeta) {
if (lastBatchMeta != null) {
kafkaConsumer.seek(tp, lastBatchMeta.getLastOffset() + 1); // seek next offset after last offset from previous batch
- LOG.debug("Seeking fetch offset to next offset after last offset from previous batch");
- } else {
- LOG.debug("Seeking fetch offset from firstPollOffsetStrategy and last commit to Kafka");
+ LOG.debug("Seeking fetch offset to next offset after last offset from previous batch for topic-partition [{}]", tp);
+ } else if (isFirstPoll(tp)) {
+ LOG.debug("Seeking fetch offset from firstPollOffsetStrategy and last commit to Kafka for topic-partition [{}]", tp);
+ firstPoll.add(tp);
final OffsetAndMetadata committedOffset = kafkaConsumer.committed(tp);
if (committedOffset != null) { // offset was committed for this TopicPartition
if (firstPollOffsetStrategy.equals(EARLIEST)) {
@@ -185,6 +187,10 @@ public class KafkaTridentSpoutEmitter<K, V> implements IOpaquePartitionedTrident
return fetchOffset;
}
+ private boolean isFirstPoll(TopicPartition tp) {
+ return !firstPoll.contains(tp);
+ }
+
// returns paused topic-partitions.
private Collection<TopicPartition> pauseTopicPartitions(TopicPartition excludedTp) {
final Set<TopicPartition> pausedTopicPartitions = new HashSet<>(kafkaConsumer.assignment());
[17/40] storm git commit: Merge branch 'STORM-2435' of
https://github.com/XC-/storm into STORM-2435
Posted by ka...@apache.org.
Merge branch 'STORM-2435' of https://github.com/XC-/storm into STORM-2435
STORM-2435: Logging levels and consistency with console.log etc
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/79f33c86
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/79f33c86
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/79f33c86
Branch: refs/heads/1.1.x-branch
Commit: 79f33c862fa0c5d5cf98aaea119b9415953763c5
Parents: a3f2946
Author: Robert Evans <ev...@yahoo-inc.com>
Authored: Wed Apr 12 20:59:06 2017 -0500
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:36:38 2017 +0900
----------------------------------------------------------------------
.../src/main/resources/resources/storm.js | 121 ++++++++++++-------
1 file changed, 75 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/79f33c86/storm-multilang/javascript/src/main/resources/resources/storm.js
----------------------------------------------------------------------
diff --git a/storm-multilang/javascript/src/main/resources/resources/storm.js b/storm-multilang/javascript/src/main/resources/resources/storm.js
index 206119c..25e0a6d 100755
--- a/storm-multilang/javascript/src/main/resources/resources/storm.js
+++ b/storm-multilang/javascript/src/main/resources/resources/storm.js
@@ -25,38 +25,67 @@
var fs = require('fs');
function Storm() {
- this.messagePart = "";
+ this.messagePart = '';
this.taskIdsCallbacks = [];
this.isFirstMessage = true;
this.separator = '\nend\n';
+ this.logLevels = {
+ trace: 0, debug: 1, info: 2, warn: 3, error: 4
+ }
}
Storm.prototype.sendMsgToParent = function(msg) {
var str = JSON.stringify(msg);
process.stdout.write(str + this.separator);
-}
+};
Storm.prototype.sync = function() {
- this.sendMsgToParent({"command":"sync"});
-}
+ this.sendMsgToParent({'command':'sync'});
+};
Storm.prototype.sendPid = function(heartbeatdir) {
var pid = process.pid;
- fs.closeSync(fs.openSync(heartbeatdir + "/" + pid, "w"));
- this.sendMsgToParent({"pid": pid})
-}
+ fs.closeSync(fs.openSync(heartbeatdir + '/' + pid, 'w'));
+ this.sendMsgToParent({'pid': pid})
+};
+Storm.prototype.sendToLogging = function(args, logLevel) {
+ var argArray = Object.keys(args).map(function(key) {
+ return (typeof args[key] === 'string') ? args[key] : JSON.stringify(args[key]);
+ });
+ var msg = argArray.join(' ');
+ this.sendMsgToParent({'command': 'log', 'msg': msg, 'level': logLevel});
+};
-Storm.prototype.log = function(msg) {
- this.sendMsgToParent({"command": "log", "msg": msg});
-}
+Storm.prototype.logTrace = function() {
+ this.sendToLogging(arguments, this.logLevels.trace);
+};
+
+Storm.prototype.logDebug = function() {
+ this.sendToLogging(arguments, this.logLevels.debug);
+};
+
+Storm.prototype.logInfo = function() {
+ this.sendToLogging(arguments, this.logLevels.info);
+};
+
+Storm.prototype.logWarn = function() {
+ this.sendToLogging(arguments, this.logLevels.warn);
+};
+
+Storm.prototype.logError = function() {
+ this.sendToLogging(arguments, this.logLevels.error);
+};
+
+// For backwards compatibility
+Storm.prototype.log = Storm.prototype.logInfo;
Storm.prototype.initSetupInfo = function(setupInfo) {
var self = this;
var callback = function() {
self.sendPid(setupInfo['pidDir']);
- }
+ };
this.initialize(setupInfo['conf'], setupInfo['context'], callback);
-}
+};
Storm.prototype.startReadingInput = function() {
var self = this;
@@ -68,7 +97,7 @@ Storm.prototype.startReadingInput = function() {
})
});
-}
+};
/**
* receives a new string chunk and returns a list of new messages with the separator removed
@@ -98,11 +127,11 @@ Storm.prototype.handleNewChunk = function(chunk) {
}
}
return messages;
-}
+};
Storm.prototype.isTaskIds = function(msg) {
return (msg instanceof Array);
-}
+};
Storm.prototype.handleNewMessage = function(msg) {
var parsedMsg = JSON.parse(msg);
@@ -115,7 +144,7 @@ Storm.prototype.handleNewMessage = function(msg) {
} else {
this.handleNewCommand(parsedMsg);
}
-}
+};
Storm.prototype.handleNewTaskId = function(taskIds) {
//When new list of task ids arrives, the callback that was passed with the corresponding emit should be called.
@@ -128,7 +157,7 @@ Storm.prototype.handleNewTaskId = function(taskIds) {
} else {
throw new Error('Something went wrong, we off the split of task id callbacks');
}
-}
+};
@@ -166,8 +195,8 @@ Storm.prototype.emit = function(messageDetails, onTaskIds) {
}
this.taskIdsCallbacks.push(onTaskIds);
- this.__emit(messageDetails);;
-}
+ this.__emit(messageDetails);
+};
/**
@@ -193,10 +222,10 @@ Storm.prototype.emit = function(messageDetails, onTaskIds) {
*/
Storm.prototype.emitDirect = function(commandDetails) {
if (!commandDetails.task) {
- throw new Error("Emit direct must receive task id!")
+ throw new Error('Emit direct must receive task id!')
}
this.__emit(commandDetails);
-}
+};
/**
* Initialize storm component according to the configuration received.
@@ -206,13 +235,13 @@ Storm.prototype.emitDirect = function(commandDetails) {
*/
Storm.prototype.initialize = function(conf, context, done) {
done();
-}
+};
Storm.prototype.run = function() {
process.stdout.setEncoding('utf8');
process.stdin.setEncoding('utf8');
this.startReadingInput();
-}
+};
function Tuple(id, component, stream, task, values) {
this.id = id;
@@ -223,12 +252,12 @@ function Tuple(id, component, stream, task, values) {
}
Tuple.prototype.isTickTuple = function(){
- return this.task === -1 && this.stream === "__tick";
-}
+ return this.task === -1 && this.stream === '__tick';
+};
Tuple.prototype.isHeartbeatTuple = function(){
- return this.task === -1 && this.stream === "__heartbeat";
-}
+ return this.task === -1 && this.stream === '__heartbeat';
+};
/**
* Base class for storm bolt.
@@ -238,7 +267,7 @@ Tuple.prototype.isHeartbeatTuple = function(){
function BasicBolt() {
Storm.call(this);
this.anchorTuple = null;
-};
+}
BasicBolt.prototype = Object.create(Storm.prototype);
BasicBolt.prototype.constructor = BasicBolt;
@@ -264,7 +293,7 @@ BasicBolt.prototype.__emit = function(commandDetails) {
}
var message = {
- command: "emit",
+ command: 'emit',
tuple: commandDetails.tuple,
stream: commandDetails.stream,
task: commandDetails.task,
@@ -272,11 +301,11 @@ BasicBolt.prototype.__emit = function(commandDetails) {
};
this.sendMsgToParent(message);
-}
+};
BasicBolt.prototype.handleNewCommand = function(command) {
var self = this;
- var tup = new Tuple(command["id"], command["comp"], command["stream"], command["task"], command["tuple"]);
+ var tup = new Tuple(command['id'], command['comp'], command['stream'], command['task'], command['tuple']);
if (tup.isHeartbeatTuple()) {
self.sync();
@@ -289,9 +318,9 @@ BasicBolt.prototype.handleNewCommand = function(command) {
return;
}
self.ack(tup);
- }
+ };
this.process(tup, callback);
-}
+};
/**
* Implement this method when creating a bolt. This is the main method that provides the logic of the bolt (what
@@ -302,12 +331,12 @@ BasicBolt.prototype.handleNewCommand = function(command) {
BasicBolt.prototype.process = function(tuple, done) {};
BasicBolt.prototype.ack = function(tup) {
- this.sendMsgToParent({"command": "ack", "id": tup.id});
-}
+ this.sendMsgToParent({'command': 'ack', 'id': tup.id});
+};
BasicBolt.prototype.fail = function(tup, err) {
- this.sendMsgToParent({"command": "fail", "id": tup.id});
-}
+ this.sendMsgToParent({'command': 'fail', 'id': tup.id});
+};
/**
* Base class for storm spout.
@@ -318,7 +347,7 @@ BasicBolt.prototype.fail = function(tup, err) {
*/
function Spout() {
Storm.call(this);
-};
+}
Spout.prototype = Object.create(Storm.prototype);
@@ -351,18 +380,18 @@ Spout.prototype.handleNewCommand = function(command) {
self.sync();
}
- if (command["command"] === "next") {
+ if (command['command'] === 'next') {
this.nextTuple(callback);
}
- if (command["command"] === "ack") {
- this.ack(command["id"], callback);
+ if (command['command'] === 'ack') {
+ this.ack(command['id'], callback);
}
- if (command["command"] === "fail") {
- this.fail(command["id"], callback);
+ if (command['command'] === 'fail') {
+ this.fail(command['id'], callback);
}
-}
+};
/**
* @param commandDetails json with the required fields:
@@ -374,7 +403,7 @@ Spout.prototype.handleNewCommand = function(command) {
*/
Spout.prototype.__emit = function(commandDetails) {
var message = {
- command: "emit",
+ command: 'emit',
tuple: commandDetails.tuple,
id: commandDetails.id,
stream: commandDetails.stream,
@@ -382,7 +411,7 @@ Spout.prototype.__emit = function(commandDetails) {
};
this.sendMsgToParent(message);
-}
+};
module.exports.BasicBolt = BasicBolt;
module.exports.Spout = Spout;
[15/40] storm git commit: Fix documentation code formatting
Posted by ka...@apache.org.
Fix documentation code formatting
Code blocks should always follow an empty line; otherwise, jekyll will
fail to properly format the code block.
Also, github's fenced code blocks (with triple backticks) in the middle
of item lists cause incorrect list numbering.
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/703afcfe
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/703afcfe
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/703afcfe
Branch: refs/heads/1.1.x-branch
Commit: 703afcfe5a09128ef22fd4d2ea20e64b7ef97af6
Parents: cf4d9e1
Author: Régis Behmo <re...@behmo.com>
Authored: Thu Apr 13 16:17:47 2017 +0200
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:33:34 2017 +0900
----------------------------------------------------------------------
docs/State-checkpointing.md | 81 ++++++------
docs/Trident-API-Overview.md | 6 +-
docs/storm-cassandra.md | 21 ++--
docs/storm-jdbc.md | 7 +-
docs/storm-kafka-client.md | 15 ++-
docs/storm-kafka.md | 258 ++++++++++++++++++++------------------
docs/storm-kinesis.md | 3 +
docs/storm-redis.md | 61 +++++++--
docs/storm-solr.md | 18 ++-
9 files changed, 272 insertions(+), 198 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/703afcfe/docs/State-checkpointing.md
----------------------------------------------------------------------
diff --git a/docs/State-checkpointing.md b/docs/State-checkpointing.md
index 3d6212c..8789508 100644
--- a/docs/State-checkpointing.md
+++ b/docs/State-checkpointing.md
@@ -22,31 +22,30 @@ For example a word count bolt could use the key value state abstraction for the
last committed by the framework during the previous run.
3. In the execute method, update the word count.
- ```java
- public class WordCountBolt extends BaseStatefulBolt<KeyValueState<String, Long>> {
- private KeyValueState<String, Long> wordCounts;
- private OutputCollector collector;
- ...
- @Override
- public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
- this.collector = collector;
- }
- @Override
- public void initState(KeyValueState<String, Long> state) {
- wordCounts = state;
- }
- @Override
- public void execute(Tuple tuple) {
- String word = tuple.getString(0);
- Integer count = wordCounts.get(word, 0);
- count++;
- wordCounts.put(word, count);
- collector.emit(tuple, new Values(word, count));
- collector.ack(tuple);
- }
- ...
- }
- ```
+ public class WordCountBolt extends BaseStatefulBolt<KeyValueState<String, Long>> {
+ private KeyValueState<String, Long> wordCounts;
+ private OutputCollector collector;
+ ...
+ @Override
+ public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
+ this.collector = collector;
+ }
+ @Override
+ public void initState(KeyValueState<String, Long> state) {
+ wordCounts = state;
+ }
+ @Override
+ public void execute(Tuple tuple) {
+ String word = tuple.getString(0);
+ Integer count = wordCounts.get(word, 0);
+ count++;
+ wordCounts.put(word, count);
+ collector.emit(tuple, new Values(word, count));
+ collector.ack(tuple);
+ }
+ ...
+ }
+
4. The framework periodically checkpoints the state of the bolt (default every second). The frequency
can be changed by setting the storm config `topology.state.checkpoint.interval.ms`
5. For state persistence, use a state provider that supports persistence by setting the `topology.state.provider` in the
@@ -56,21 +55,21 @@ in the extlib directory.
6. The state provider properties can be overridden by setting `topology.state.provider.config`. For Redis state this is a
json config with the following properties.
- ```
- {
- "keyClass": "Optional fully qualified class name of the Key type.",
- "valueClass": "Optional fully qualified class name of the Value type.",
- "keySerializerClass": "Optional Key serializer implementation class.",
- "valueSerializerClass": "Optional Value Serializer implementation class.",
- "jedisPoolConfig": {
- "host": "localhost",
- "port": 6379,
- "timeout": 2000,
- "database": 0,
- "password": "xyz"
- }
- }
- ```
+```
+{
+ "keyClass": "Optional fully qualified class name of the Key type.",
+ "valueClass": "Optional fully qualified class name of the Value type.",
+ "keySerializerClass": "Optional Key serializer implementation class.",
+ "valueSerializerClass": "Optional Value Serializer implementation class.",
+ "jedisPoolConfig": {
+ "host": "localhost",
+ "port": 6379,
+ "timeout": 2000,
+ "database": 0,
+ "password": "xyz"
+ }
+}
+```
## Checkpoint mechanism
Checkpoint is triggered by an internal checkpoint spout at the specified `topology.state.checkpoint.interval.ms`. If there is
@@ -123,6 +122,7 @@ In order to provide the at-least once guarantee, all bolts in a stateful topolog
### IStateful bolt hooks
IStateful bolt interface provides hook methods where in the stateful bolts could implement some custom actions.
+
```java
/**
* This is a hook for the component to perform some actions just before the
@@ -142,6 +142,7 @@ IStateful bolt interface provides hook methods where in the stateful bolts could
*/
void preRollback();
```
+
This is optional and stateful bolts are not expected to provide any implementation. This is provided so that other
system level components can be built on top of the stateful abstractions where we might want to take some actions before the
stateful bolt's state is prepared, committed or rolled back.
http://git-wip-us.apache.org/repos/asf/storm/blob/703afcfe/docs/Trident-API-Overview.md
----------------------------------------------------------------------
diff --git a/docs/Trident-API-Overview.md b/docs/Trident-API-Overview.md
index 309127d..ef743db 100644
--- a/docs/Trident-API-Overview.md
+++ b/docs/Trident-API-Overview.md
@@ -161,6 +161,7 @@ mystream.flatMap(new Split(), new Fields("word"))
This could be useful for debugging to see the tuples as they flow past a certain point in a pipeline.
For example, the below code would print the result of converting the words to uppercase before they are passed to `groupBy`
+
```java
mystream.flatMap(new Split()).map(new UpperCase())
.peek(new Consumer() {
@@ -206,14 +207,14 @@ Partition 2:
[74, 37]
[51, 49]
[37, 98]
-
```
`minBy` operation can be applied on the above stream of tuples like below which results in emitting tuples with minimum values of `count` field in each partition.
-``` java
+```java
mystream.minBy(new Fields("count"))
```
+
Result of the above code on mentioned partitions is:
```
@@ -227,7 +228,6 @@ Partition 1:
Partition 2:
[82, 23]
-
```
You can look at other `min` and `minBy` operations on Stream
http://git-wip-us.apache.org/repos/asf/storm/blob/703afcfe/docs/storm-cassandra.md
----------------------------------------------------------------------
diff --git a/docs/storm-cassandra.md b/docs/storm-cassandra.md
index 47fabbd..61beb10 100644
--- a/docs/storm-cassandra.md
+++ b/docs/storm-cassandra.md
@@ -29,14 +29,14 @@ The following properties may be passed to storm configuration.
### CassandraWriterBolt
####Static import
-```java
+```java
import static org.apache.storm.cassandra.DynamicStatementBuilder.*
-
```
#### Insert Query Builder
##### Insert query including only the specified tuple fields.
+
```java
new CassandraWriterBolt(
@@ -50,6 +50,7 @@ import static org.apache.storm.cassandra.DynamicStatementBuilder.*
```
##### Insert query including all tuple fields.
+
```java
new CassandraWriterBolt(
@@ -61,8 +62,8 @@ import static org.apache.storm.cassandra.DynamicStatementBuilder.*
```
##### Insert multiple queries from one input tuple.
-```java
+```java
new CassandraWriterBolt(
async(
simpleQuery("INSERT INTO titles_per_album (title,year,performer,genre,tracks) VALUES (?, ?, ?, ?, ?);").with(all())),
@@ -72,8 +73,8 @@ import static org.apache.storm.cassandra.DynamicStatementBuilder.*
```
##### Insert query using QueryBuilder
-```java
+```java
new CassandraWriterBolt(
async(
simpleQuery("INSERT INTO album (title,year,perfomer,genre,tracks) VALUES (?, ?, ?, ?, ?);")
@@ -83,8 +84,8 @@ import static org.apache.storm.cassandra.DynamicStatementBuilder.*
```
##### Insert query with static bound query
-```java
+```java
new CassandraWriterBolt(
async(
boundQuery("INSERT INTO album (title,year,performer,genre,tracks) VALUES (?, ?, ?, ?, ?);")
@@ -94,8 +95,8 @@ import static org.apache.storm.cassandra.DynamicStatementBuilder.*
```
##### Insert query with static bound query using named setters and aliases
-```java
+```java
new CassandraWriterBolt(
async(
boundQuery("INSERT INTO album (title,year,performer,genre,tracks) VALUES (:ti, :ye, :pe, :ge, :tr);")
@@ -111,24 +112,24 @@ import static org.apache.storm.cassandra.DynamicStatementBuilder.*
```
##### Insert query with bound statement load from storm configuration
-```java
+```java
new CassandraWriterBolt(
boundQuery(named("insertIntoAlbum"))
.bind(all());
```
##### Insert query with bound statement load from tuple field
-```java
+```java
new CassandraWriterBolt(
boundQuery(namedByField("cql"))
.bind(all());
```
##### Insert query with batch statement
-```java
+```java
// Logged
new CassandraWriterBolt(loggedBatch(
simpleQuery("INSERT INTO titles_per_album (title,year,performer,genre,tracks) VALUES (?, ?, ?, ?, ?);").with(all())),
@@ -205,6 +206,7 @@ builder.setBolt("BOLT_WRITER", bolt, 4)
### Trident API support
storm-cassandra support Trident `state` API for `inserting` data into Cassandra.
+
```java
CassandraState.Options options = new CassandraState.Options(new CassandraContext());
CQLStatementTupleMapper insertTemperatureValues = boundQuery(
@@ -219,6 +221,7 @@ storm-cassandra support Trident `state` API for `inserting` data into Cassandra.
```
Below `state` API for `querying` data from Cassandra.
+
```java
CassandraState.Options options = new CassandraState.Options(new CassandraContext());
CQLStatementTupleMapper insertTemperatureValues = boundQuery("SELECT name FROM weather.station WHERE id = ?")
http://git-wip-us.apache.org/repos/asf/storm/blob/703afcfe/docs/storm-jdbc.md
----------------------------------------------------------------------
diff --git a/docs/storm-jdbc.md b/docs/storm-jdbc.md
index 15aa2a3..66bedde 100644
--- a/docs/storm-jdbc.md
+++ b/docs/storm-jdbc.md
@@ -63,7 +63,7 @@ You can optionally specify a query timeout seconds param that specifies max seco
The default is set to value of topology.message.timeout.secs and a value of -1 will indicate not to set any query timeout.
You should set the query timeout value to be <= topology.message.timeout.secs.
- ```java
+```java
Map hikariConfigMap = Maps.newHashMap();
hikariConfigMap.put("dataSourceClassName","com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
hikariConfigMap.put("dataSource.url", "jdbc:mysql://localhost/test");
@@ -81,7 +81,7 @@ JdbcInsertBolt userPersistanceBolt = new JdbcInsertBolt(connectionProvider, simp
JdbcInsertBolt userPersistanceBolt = new JdbcInsertBolt(connectionProvider, simpleJdbcMapper)
.withInsertQuery("insert into user values (?,?)")
.withQueryTimeoutSecs(30);
- ```
+```
### SimpleJdbcMapper
`storm-jdbc` includes a general purpose `JdbcMapper` implementation called `SimpleJdbcMapper` that can map Storm
@@ -112,6 +112,7 @@ method will return the columns in the order in which Jdbc connection instance's
**If you specified your own insert query to `JdbcInsertBolt` you must initialize `SimpleJdbcMapper` with explicit columnschema such that the schema has columns in the same order as your insert queries.**
For example if your insert query is `Insert into user (user_id, user_name) values (?,?)` then your `SimpleJdbcMapper` should be initialized with the following statements:
+
```java
List<Column> columnSchema = Lists.newArrayList(
new Column("user_id", java.sql.Types.INTEGER),
@@ -224,6 +225,7 @@ A runnable example can be found in the `src/test/java/topology` directory.
* Ensure you have included JDBC implementation dependency for your chosen database as part of your build configuration.
* The test topologies executes the following queries so your intended DB must support these queries for test topologies
to work.
+
```SQL
create table if not exists user (user_id integer, user_name varchar(100), dept_name varchar(100), create_date date);
create table if not exists department (dept_id integer, dept_name varchar(100));
@@ -272,6 +274,7 @@ You can generate a single jar with dependencies using mvn assembly plugin. To us
```
Mysql Example:
+
```
storm jar ~/repo/incubator-storm/external/storm-jdbc/target/storm-jdbc-0.10.0-SNAPSHOT-jar-with-dependencies.jar org.apache.storm.jdbc.topology.UserPersistanceTopology com.mysql.jdbc.jdbc2.optional.MysqlDataSource jdbc:mysql://localhost/test root password UserPersistenceTopology
```
http://git-wip-us.apache.org/repos/asf/storm/blob/703afcfe/docs/storm-kafka-client.md
----------------------------------------------------------------------
diff --git a/docs/storm-kafka-client.md b/docs/storm-kafka-client.md
index d1776d2..c687261 100644
--- a/docs/storm-kafka-client.md
+++ b/docs/storm-kafka-client.md
@@ -35,11 +35,13 @@ These should be specified while constructing an instance of FieldNameBasedTupleT
###KafkaTopicSelector and trident KafkaTopicSelector
This interface has only one method
+
```java
public interface KafkaTopicSelector {
String getTopics(Tuple/TridentTuple tuple);
}
```
+
The implementation of this interface should return the topic to which the tuple's key/message mapping needs to be published
You can return a null and the message will be ignored. If you have one static topic name then you can use
DefaultTopicSelector.java and set the name of the topic in the constructor.
@@ -55,6 +57,7 @@ These are also defined in `org.apache.kafka.clients.producer.ProducerConfig`
###Using wildcard kafka topic match
You can do a wildcard topic match by adding the following config
+
```
Config config = new Config();
config.put("kafka.topic.wildcard.match",true);
@@ -67,6 +70,7 @@ After this you can specify a wildcard topic for matching e.g. clickstream.*.log.
###Putting it all together
For the bolt :
+
```java
TopologyBuilder builder = new TopologyBuilder();
@@ -174,30 +178,30 @@ The API is written with java 8 lambda expressions in mind. It works with java7
#### Create a Simple Insecure Spout
The following will consume all events published to "topic" and send them to MyBolt with the fields "topic", "partition", "offset", "key", "value".
+
```java
final TopologyBuilder tp = new TopologyBuilder();
tp.setSpout("kafka_spout", new KafkaSpout<>(KafkaSpoutConfig.builder("127.0.0.1:" + port, "topic").build()), 1);
tp.setBolt("bolt", new myBolt()).shuffleGrouping("kafka_spout");
...
-
```
#### Wildcard Topics
Wildcard topics will consume from all topics that exist in the specified brokers list and match the pattern. So in the following example
"topic", "topic_foo" and "topic_bar" will all match the pattern "topic.*", but "not_my_topic" would not match.
+
```java
final TopologyBuilder tp = new TopologyBuilder();
tp.setSpout("kafka_spout", new KafkaSpout<>(KafkaSpoutConfig.builder("127.0.0.1:" + port, Pattern.compile("topic.*")).build()), 1);
tp.setBolt("bolt", new myBolt()).shuffleGrouping("kafka_spout");
...
-
```
#### Multiple Streams
+
This uses java 8 lambda expressions.
-```java
final TopologyBuilder tp = new TopologyBuilder();
@@ -212,7 +216,6 @@ tp.setSpout("kafka_spout", new KafkaSpout<>(KafkaSpoutConfig.builder("127.0.0.1:
tp.setBolt("bolt", new myBolt()).shuffleGrouping("kafka_spout", "STREAM_1");
tp.setBolt("another", new myOtherBolt()).shuffleGrouping("kafka_spout", "STREAM_2");
...
-
```
#### Trident
@@ -223,7 +226,6 @@ final Stream spoutStream = tridentTopology.newStream("kafkaSpout",
new KafkaTridentSpoutOpaque<>(KafkaSpoutConfig.builder("127.0.0.1:" + port, Pattern.compile("topic.*")).build()))
.parallelismHint(1)
...
-
```
Trident does not support multiple streams and will ignore any streams set for output. If however the Fields are not identical for each
@@ -239,6 +241,7 @@ specific stream. To do this you will need to return an instance of `org.apache.
specific stream the tuple should go to.
For Example:
+
```java
return new KafkaTuple(1, 2, 3, 4).routedTo("bar");
```
@@ -261,6 +264,7 @@ please be careful when using these or implementing your own.
## Use the Maven Shade Plugin to Build the Uber Jar
Add the following to `REPO_HOME/storm/external/storm-kafka-client/pom.xml`
+
```xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -363,6 +367,7 @@ To enable it, you need to:
* enable *AutoCommitMode* in Kafka consumer configuration;
Here's one example to set AutoCommitMode in KafkaSpout:
+
```java
KafkaSpoutConfig<String, String> kafkaConf = KafkaSpoutConfig
.builder(String bootstrapServers, String ... topics)
http://git-wip-us.apache.org/repos/asf/storm/blob/703afcfe/docs/storm-kafka.md
----------------------------------------------------------------------
diff --git a/docs/storm-kafka.md b/docs/storm-kafka.md
index c69845d..d521d13 100644
--- a/docs/storm-kafka.md
+++ b/docs/storm-kafka.md
@@ -17,10 +17,12 @@ Currently, we support the following two implementations:
####ZkHosts
ZkHosts is what you should use if you want to dynamically track Kafka broker to partition mapping. This class uses
Kafka's ZooKeeper entries to track brokerHost -> partition mapping. You can instantiate an object by calling
+
```java
- public ZkHosts(String brokerZkStr, String brokerZkPath)
- public ZkHosts(String brokerZkStr)
+public ZkHosts(String brokerZkStr, String brokerZkPath)
+public ZkHosts(String brokerZkStr)
```
+
Where brokerZkStr is just ip:port (e.g. localhost:2181). brokerZkPath is the root directory under which all the topics and
partition information is stored. By default this is /brokers which is what the default Kafka implementation uses.
@@ -32,21 +34,22 @@ This is an alternative implementation where broker -> partition information is s
of this class, you need to first construct an instance of GlobalPartitionInformation.
```java
- Broker brokerForPartition0 = new Broker("localhost");//localhost:9092
- Broker brokerForPartition1 = new Broker("localhost", 9092);//localhost:9092 but we specified the port explicitly
- Broker brokerForPartition2 = new Broker("localhost:9092");//localhost:9092 specified as one string.
- GlobalPartitionInformation partitionInfo = new GlobalPartitionInformation();
- partitionInfo.addPartition(0, brokerForPartition0);//mapping from partition 0 to brokerForPartition0
- partitionInfo.addPartition(1, brokerForPartition1);//mapping from partition 1 to brokerForPartition1
- partitionInfo.addPartition(2, brokerForPartition2);//mapping from partition 2 to brokerForPartition2
- StaticHosts hosts = new StaticHosts(partitionInfo);
+Broker brokerForPartition0 = new Broker("localhost");//localhost:9092
+Broker brokerForPartition1 = new Broker("localhost", 9092);//localhost:9092 but we specified the port explicitly
+Broker brokerForPartition2 = new Broker("localhost:9092");//localhost:9092 specified as one string.
+GlobalPartitionInformation partitionInfo = new GlobalPartitionInformation();
+partitionInfo.addPartition(0, brokerForPartition0);//mapping from partition 0 to brokerForPartition0
+partitionInfo.addPartition(1, brokerForPartition1);//mapping from partition 1 to brokerForPartition1
+partitionInfo.addPartition(2, brokerForPartition2);//mapping from partition 2 to brokerForPartition2
+StaticHosts hosts = new StaticHosts(partitionInfo);
```
###KafkaConfig
The second thing needed for constructing a kafkaSpout is an instance of KafkaConfig.
+
```java
- public KafkaConfig(BrokerHosts hosts, String topic)
- public KafkaConfig(BrokerHosts hosts, String topic, String clientId)
+public KafkaConfig(BrokerHosts hosts, String topic)
+public KafkaConfig(BrokerHosts hosts, String topic, String clientId)
```
The BrokerHosts can be any implementation of BrokerHosts interface as described above. The topic is name of Kafka topic.
@@ -57,47 +60,51 @@ There are 2 extensions of KafkaConfig currently in use.
Spoutconfig is an extension of KafkaConfig that supports additional fields with ZooKeeper connection info and for controlling
behavior specific to KafkaSpout. The Zkroot will be used as root to store your consumer's offset. The id should uniquely
identify your spout.
+
```java
public SpoutConfig(BrokerHosts hosts, String topic, String zkRoot, String id);
public SpoutConfig(BrokerHosts hosts, String topic, String id);
```
+
In addition to these parameters, SpoutConfig contains the following fields that control how KafkaSpout behaves:
-```java
- // setting for how often to save the current Kafka offset to ZooKeeper
- public long stateUpdateIntervalMs = 2000;
-
- // Retry strategy for failed messages
- public String failedMsgRetryManagerClass = ExponentialBackoffMsgRetryManager.class.getName();
-
- // Exponential back-off retry settings. These are used by ExponentialBackoffMsgRetryManager for retrying messages after a bolt
- // calls OutputCollector.fail(). These come into effect only if ExponentialBackoffMsgRetryManager is being used.
- // Initial delay between successive retries
- public long retryInitialDelayMs = 0;
- public double retryDelayMultiplier = 1.0;
-
- // Maximum delay between successive retries
- public long retryDelayMaxMs = 60 * 1000;
- // Failed message will be retried infinitely if retryLimit is less than zero.
- public int retryLimit = -1;
+```java
+// setting for how often to save the current Kafka offset to ZooKeeper
+public long stateUpdateIntervalMs = 2000;
+
+// Retry strategy for failed messages
+public String failedMsgRetryManagerClass = ExponentialBackoffMsgRetryManager.class.getName();
+
+// Exponential back-off retry settings. These are used by ExponentialBackoffMsgRetryManager for retrying messages after a bolt
+// calls OutputCollector.fail(). These come into effect only if ExponentialBackoffMsgRetryManager is being used.
+// Initial delay between successive retries
+public long retryInitialDelayMs = 0;
+public double retryDelayMultiplier = 1.0;
+
+// Maximum delay between successive retries
+public long retryDelayMaxMs = 60 * 1000;
+// Failed message will be retried infinitely if retryLimit is less than zero.
+public int retryLimit = -1;
```
+
Core KafkaSpout only accepts an instance of SpoutConfig.
TridentKafkaConfig is another extension of KafkaConfig.
TridentKafkaEmitter only accepts TridentKafkaConfig.
The KafkaConfig class also has bunch of public variables that controls your application's behavior. Here are defaults:
+
```java
- public int fetchSizeBytes = 1024 * 1024;
- public int socketTimeoutMs = 10000;
- public int fetchMaxWait = 10000;
- public int bufferSizeBytes = 1024 * 1024;
- public MultiScheme scheme = new RawMultiScheme();
- public boolean ignoreZkOffsets = false;
- public long startOffsetTime = kafka.api.OffsetRequest.EarliestTime();
- public long maxOffsetBehind = Long.MAX_VALUE;
- public boolean useStartOffsetTimeIfOffsetOutOfRange = true;
- public int metricsTimeBucketSizeInSecs = 60;
+public int fetchSizeBytes = 1024 * 1024;
+public int socketTimeoutMs = 10000;
+public int fetchMaxWait = 10000;
+public int bufferSizeBytes = 1024 * 1024;
+public MultiScheme scheme = new RawMultiScheme();
+public boolean ignoreZkOffsets = false;
+public long startOffsetTime = kafka.api.OffsetRequest.EarliestTime();
+public long maxOffsetBehind = Long.MAX_VALUE;
+public boolean useStartOffsetTimeIfOffsetOutOfRange = true;
+public int metricsTimeBucketSizeInSecs = 60;
```
Most of them are self explanatory except MultiScheme.
@@ -106,8 +113,8 @@ MultiScheme is an interface that dictates how the ByteBuffer consumed from Kafka
also controls the naming of your output field.
```java
- public Iterable<List<Object>> deserialize(ByteBuffer ser);
- public Fields getOutputFields();
+public Iterable<List<Object>> deserialize(ByteBuffer ser);
+public Fields getOutputFields();
```
The default `RawMultiScheme` just takes the `ByteBuffer` and returns a tuple with the ByteBuffer converted to a `byte[]`. The name of the outputField is "bytes". There are alternative implementations like `SchemeAsMultiScheme` and `KeyValueSchemeAsMultiScheme` which can convert the `ByteBuffer` to `String`.
@@ -117,7 +124,6 @@ which has an additional deserialize method that accepts the message `ByteBuffer`
```java
public Iterable<List<Object>> deserializeMessageWithMetadata(ByteBuffer message, Partition partition, long offset)
-
```
This is useful for auditing/replaying messages from arbitrary points on a Kafka topic, saving the partition and offset of each message of a discrete stream instead of persisting the entire message.
@@ -183,6 +189,7 @@ KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);
```
#### Trident Spout
+
```java
TridentTopology topology = new TridentTopology();
BrokerHosts zk = new ZkHosts("localhost");
@@ -227,21 +234,21 @@ When building a project with storm-kafka, you must explicitly add the Kafka depe
use Kafka 0.8.1.1 built against Scala 2.10, you would use the following dependency in your `pom.xml`:
```xml
- <dependency>
- <groupId>org.apache.kafka</groupId>
- <artifactId>kafka_2.10</artifactId>
- <version>0.8.1.1</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+<dependency>
+ <groupId>org.apache.kafka</groupId>
+ <artifactId>kafka_2.10</artifactId>
+ <version>0.8.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+</dependency>
```
Note that the ZooKeeper and log4j dependencies are excluded to prevent version conflicts with Storm's dependencies.
@@ -249,11 +256,12 @@ Note that the ZooKeeper and log4j dependencies are excluded to prevent version c
You can also override the kafka dependency version while building from maven, with parameter `storm.kafka.version` and `storm.kafka.artifact.id`
e.g. `mvn clean install -Dstorm.kafka.artifact.id=kafka_2.11 -Dstorm.kafka.version=0.9.0.1`
-When selecting a kafka dependency version, you should ensure -
- 1. kafka api is compatible with storm-kafka. Currently, only 0.9.x and 0.8.x client API is supported by storm-kafka
- module. If you want to use a higher version, storm-kafka-client module should be used instead.
- 2. The kafka client selected by you should be wire compatible with the broker. e.g. 0.9.x client will not work with
- 0.8.x broker.
+When selecting a kafka dependency version, you should ensure -
+
+1. kafka api is compatible with storm-kafka. Currently, only 0.9.x and 0.8.x client API is supported by storm-kafka
+module. If you want to use a higher version, storm-kafka-client module should be used instead.
+2. The kafka client selected by you should be wire compatible with the broker. e.g. 0.9.x client will not work with
+0.8.x broker.
##Writing to Kafka as part of your topology
@@ -267,8 +275,8 @@ You need to provide implementation of following 2 interfaces
These interfaces have 2 methods defined:
```java
- K getKeyFromTuple(Tuple/TridentTuple tuple);
- V getMessageFromTuple(Tuple/TridentTuple tuple);
+K getKeyFromTuple(Tuple/TridentTuple tuple);
+V getMessageFromTuple(Tuple/TridentTuple tuple);
```
As the name suggests, these methods are called to map a tuple to Kafka key and Kafka message. If you just want one field
@@ -281,6 +289,7 @@ These should be specified while constructing and instance of FieldNameBasedTuple
###KafkaTopicSelector and trident KafkaTopicSelector
This interface has only one method
+
```java
public interface KafkaTopicSelector {
String getTopics(Tuple/TridentTuple tuple);
@@ -300,10 +309,10 @@ Section "Important configuration properties for the producer" for more details.
###Using wildcard kafka topic match
You can do a wildcard topic match by adding the following config
-```
- Config config = new Config();
- config.put("kafka.topic.wildcard.match",true);
+```java
+Config config = new Config();
+config.put("kafka.topic.wildcard.match",true);
```
After this you can specify a wildcard topic for matching e.g. clickstream.*.log. This will match all streams matching clickstream.my.log, clickstream.cart.log etc
@@ -312,64 +321,69 @@ After this you can specify a wildcard topic for matching e.g. clickstream.*.log.
###Putting it all together
For the bolt :
+
```java
- TopologyBuilder builder = new TopologyBuilder();
-
- Fields fields = new Fields("key", "message");
- FixedBatchSpout spout = new FixedBatchSpout(fields, 4,
- new Values("storm", "1"),
- new Values("trident", "1"),
- new Values("needs", "1"),
- new Values("javadoc", "1")
- );
- spout.setCycle(true);
- builder.setSpout("spout", spout, 5);
- //set producer properties.
- Properties props = new Properties();
- props.put("bootstrap.servers", "localhost:9092");
- props.put("acks", "1");
- props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
- props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
-
- KafkaBolt bolt = new KafkaBolt()
- .withProducerProperties(props)
- .withTopicSelector(new DefaultTopicSelector("test"))
- .withTupleToKafkaMapper(new FieldNameBasedTupleToKafkaMapper());
- builder.setBolt("forwardToKafka", bolt, 8).shuffleGrouping("spout");
-
- Config conf = new Config();
-
- StormSubmitter.submitTopology("kafkaboltTest", conf, builder.createTopology());
+TopologyBuilder builder = new TopologyBuilder();
+
+Fields fields = new Fields("key", "message");
+FixedBatchSpout spout = new FixedBatchSpout(fields, 4,
+ new Values("storm", "1"),
+ new Values("trident", "1"),
+ new Values("needs", "1"),
+ new Values("javadoc", "1")
+);
+spout.setCycle(true);
+builder.setSpout("spout", spout, 5);
+//set producer properties.
+Properties props = new Properties();
+props.put("bootstrap.servers", "localhost:9092");
+props.put("acks", "1");
+props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
+props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
+
+KafkaBolt bolt = new KafkaBolt()
+ .withProducerProperties(props)
+ .withTopicSelector(new DefaultTopicSelector("test"))
+ .withTupleToKafkaMapper(new FieldNameBasedTupleToKafkaMapper());
+builder.setBolt("forwardToKafka", bolt, 8).shuffleGrouping("spout");
+
+Config conf = new Config();
+
+StormSubmitter.submitTopology("kafkaboltTest", conf, builder.createTopology());
```
For Trident:
```java
- Fields fields = new Fields("word", "count");
- FixedBatchSpout spout = new FixedBatchSpout(fields, 4,
- new Values("storm", "1"),
- new Values("trident", "1"),
- new Values("needs", "1"),
- new Values("javadoc", "1")
- );
- spout.setCycle(true);
-
- TridentTopology topology = new TridentTopology();
- Stream stream = topology.newStream("spout1", spout);
-
- //set producer properties.
- Properties props = new Properties();
- props.put("bootstrap.servers", "localhost:9092");
- props.put("acks", "1");
- props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
- props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
-
- TridentKafkaStateFactory stateFactory = new TridentKafkaStateFactory()
- .withProducerProperties(props)
- .withKafkaTopicSelector(new DefaultTopicSelector("test"))
- .withTridentTupleToKafkaMapper(new FieldNameBasedTupleToKafkaMapper("word", "count"));
- stream.partitionPersist(stateFactory, fields, new TridentKafkaUpdater(), new Fields());
-
- Config conf = new Config();
- StormSubmitter.submitTopology("kafkaTridentTest", conf, topology.build());
-```
\ No newline at end of file
+Fields fields = new Fields("word", "count");
+FixedBatchSpout spout = new FixedBatchSpout(fields, 4,
+ new Values("storm", "1"),
+ new Values("trident", "1"),
+ new Values("needs", "1"),
+ new Values("javadoc", "1")
+);
+spout.setCycle(true);
+
+TridentTopology topology = new TridentTopology();
+Stream stream = topology.newStream("spout1", spout);
+
+//set producer properties.
+Properties props = new Properties();
+props.put("bootstrap.servers", "localhost:9092");
+props.put("acks", "1");
+props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
+props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
+
+TridentKafkaStateFactory stateFactory = new TridentKafkaStateFactory()
+ .withProducerProperties(props)
+ .withKafkaTopicSelector(new DefaultTopicSelector("test"))
+ .withTridentTupleToKafkaMapper(new FieldNameBasedTupleToKafkaMapper("word", "count"));
+stream.partitionPersist(stateFactory, fields, new TridentKafkaUpdater(), new Fields());
+
+Config conf = new Config();
+StormSubmitter.submitTopology("kafkaTridentTest", conf, topology.build());
+```
+
+## Committer Sponsors
+
+ * P. Taylor Goetz ([ptgoetz@apache.org](mailto:ptgoetz@apache.org))
http://git-wip-us.apache.org/repos/asf/storm/blob/703afcfe/docs/storm-kinesis.md
----------------------------------------------------------------------
diff --git a/docs/storm-kinesis.md b/docs/storm-kinesis.md
index b23c10d..69c52bb 100644
--- a/docs/storm-kinesis.md
+++ b/docs/storm-kinesis.md
@@ -25,6 +25,7 @@ public class KinesisSpoutTopology {
}
}
```
+
As you can see above the spout takes an object of KinesisConfig in its constructor. The constructor of KinesisConfig takes 8 objects as explained below.
#### `String` streamName
@@ -38,6 +39,7 @@ will need to clear the state of zookeeper node used for storing sequence numbers
#### `RecordToTupleMapper` recordToTupleMapper
an implementation of `RecordToTupleMapper` interface that spout will call to convert a kinesis record to a storm tuple. It has two methods. getOutputFields
tells the spout the fields that will be present in the tuple emitted from the getTuple method. If getTuple returns null, the record will be acked
+
```java
Fields getOutputFields ();
List<Object> getTuple (Record record);
@@ -53,6 +55,7 @@ mechanism for failed messages. That implementation has two constructors. Default
subsequent retires at Math.pow(2, i-1) where i is the retry number in the range 2 to LONG.MAX_LONG. 2 represents the base for exponential function in seconds.
Other constructor takes retry interval in millis for first retry as first argument, base for exponential function in seconds as second argument and number of
retries as third argument. The methods of this interface and its working in accord with the spout is explained below
+
```java
boolean failed (KinesisMessageId messageId);
KinesisMessageId getNextFailedMessageToRetry ();
http://git-wip-us.apache.org/repos/asf/storm/blob/703afcfe/docs/storm-redis.md
----------------------------------------------------------------------
diff --git a/docs/storm-redis.md b/docs/storm-redis.md
index 87541b9..1226e9b 100644
--- a/docs/storm-redis.md
+++ b/docs/storm-redis.md
@@ -25,18 +25,20 @@ use it as a maven dependency:
### For normal Bolt
-Storm-redis provides basic Bolt implementations, ```RedisLookupBolt``` and ```RedisStoreBolt```.
+Storm-redis provides basic Bolt implementations, `RedisLookupBolt` and `RedisStoreBolt`, and `RedisFilterBolt`.
-As name represents its usage, ```RedisLookupBolt``` retrieves value from Redis using key, and ```RedisStoreBolt``` stores key / value to Redis. One tuple will be matched to one key / value pair, and you can define match pattern to ```TupleMapper```.
+As name represents its usage, `RedisLookupBolt` retrieves value from Redis using key, and `RedisStoreBolt` stores key / value to Redis, and `RedisFilterBolt` filters out tuple which key or field doesn't exist on Redis.
-You can also choose data type from ```RedisDataTypeDescription``` to use. Please refer ```RedisDataTypeDescription.RedisDataType``` to see what data types are supported. In some data types (hash and sorted set), it requires additional key and converted key from tuple becomes element.
+One tuple will be matched to one key / value pair, and you can define match pattern to `TupleMapper`.
-These interfaces are combined with ```RedisLookupMapper``` and ```RedisStoreMapper``` which fit ```RedisLookupBolt``` and ```RedisStoreBolt``` respectively.
+You can also choose data type from `RedisDataTypeDescription` to use. Please refer `RedisDataTypeDescription.RedisDataType` to see what data types are supported. In some data types (hash and sorted set, and set if only RedisFilterBolt), it requires additional key and converted key from tuple becomes element.
+
+These interfaces are combined with `RedisLookupMapper` and `RedisStoreMapper` and `RedisFilterMapper` which fit `RedisLookupBolt` and `RedisStoreBolt`, and `RedisFilterBolt` respectively.
+(When you want to implement RedisFilterMapper, be sure to set declareOutputFields() to declare same fields to input stream, since FilterBolt forwards input tuples when they exist on Redis.)
#### RedisLookupBolt example
```java
-
class WordCountRedisLookupMapper implements RedisLookupMapper {
private RedisDataTypeDescription description;
private final String hashKey = "wordCount";
@@ -74,21 +76,59 @@ class WordCountRedisLookupMapper implements RedisLookupMapper {
return null;
}
}
-
```
```java
-
JedisPoolConfig poolConfig = new JedisPoolConfig.Builder()
.setHost(host).setPort(port).build();
RedisLookupMapper lookupMapper = new WordCountRedisLookupMapper();
RedisLookupBolt lookupBolt = new RedisLookupBolt(poolConfig, lookupMapper);
```
-#### RedisStoreBolt example
+#### RedisFilterBolt example
```java
+class BlacklistWordFilterMapper implements RedisFilterMapper {
+ private RedisDataTypeDescription description;
+ private final String setKey = "blacklist";
+
+ public BlacklistWordFilterMapper() {
+ description = new RedisDataTypeDescription(
+ RedisDataTypeDescription.RedisDataType.SET, setKey);
+ }
+
+ @Override
+ public void declareOutputFields(OutputFieldsDeclarer declarer) {
+ declarer.declare(new Fields("word", "count"));
+ }
+ @Override
+ public RedisDataTypeDescription getDataTypeDescription() {
+ return description;
+ }
+
+ @Override
+ public String getKeyFromTuple(ITuple tuple) {
+ return tuple.getStringByField("word");
+ }
+
+ @Override
+ public String getValueFromTuple(ITuple tuple) {
+ return null;
+ }
+}
+```
+
+```java
+JedisPoolConfig poolConfig = new JedisPoolConfig.Builder()
+ .setHost(host).setPort(port).build();
+RedisFilterMapper filterMapper = new BlacklistWordFilterMapper();
+RedisFilterBolt filterBolt = new RedisFilterBolt(poolConfig, filterMapper);
+```
+
+#### RedisStoreBolt example
+
+```java
class WordCountStoreMapper implements RedisStoreMapper {
private RedisDataTypeDescription description;
private final String hashKey = "wordCount";
@@ -116,7 +156,6 @@ class WordCountStoreMapper implements RedisStoreMapper {
```
```java
-
JedisPoolConfig poolConfig = new JedisPoolConfig.Builder()
.setHost(host).setPort(port).build();
RedisStoreMapper storeMapper = new WordCountStoreMapper();
@@ -128,7 +167,6 @@ RedisStoreBolt storeBolt = new RedisStoreBolt(poolConfig, storeMapper);
If your scenario doesn't fit ```RedisStoreBolt``` and ```RedisLookupBolt```, storm-redis also provides ```AbstractRedisBolt``` to let you extend and apply your business logic.
```java
-
public static class LookupWordTotalCountBolt extends AbstractRedisBolt {
private static final Logger LOG = LoggerFactory.getLogger(LookupWordTotalCountBolt.class);
private static final Random RANDOM = new Random();
@@ -174,7 +212,6 @@ If your scenario doesn't fit ```RedisStoreBolt``` and ```RedisLookupBolt```, sto
declarer.declare(new Fields("wordName", "count"));
}
}
-
```
### Trident State usage
@@ -184,6 +221,7 @@ If your scenario doesn't fit ```RedisStoreBolt``` and ```RedisLookupBolt```, sto
2. RedisClusterState and RedisClusterMapState, which provide JedisCluster interface, just for redis cluster.
RedisState
+
```java
JedisPoolConfig poolConfig = new JedisPoolConfig.Builder()
.setHost(redisHost).setPort(redisPort)
@@ -207,6 +245,7 @@ RedisState
```
RedisClusterState
+
```java
Set<InetSocketAddress> nodes = new HashSet<InetSocketAddress>();
for (String hostPort : redisHostPort.split(",")) {
http://git-wip-us.apache.org/repos/asf/storm/blob/703afcfe/docs/storm-solr.md
----------------------------------------------------------------------
diff --git a/docs/storm-solr.md b/docs/storm-solr.md
index 4f5106d..7a0cb50 100644
--- a/docs/storm-solr.md
+++ b/docs/storm-solr.md
@@ -31,6 +31,7 @@ describe in detail the two key components of the Storm Solr integration, the `So
```
## Trident Topology With Fields Mapper
+
```java
new SolrStateFactory(solrConfig, solrMapper);
@@ -73,7 +74,8 @@ be a String with the contents in JSON format, or a Java object that will be seri
Code snippet illustrating how to create a `SolrJsonMapper` object to update the `gettingstarted` Solr collection with JSON content
declared in the tuple field with name "JSON"
-``` java
+
+```java
SolrMapper solrMapper = new SolrJsonMapper.Builder("gettingstarted", "JSON").build();
```
@@ -96,7 +98,7 @@ Code snippet illustrating how to create a `SolrFieldsMapper` object to update th
field separates each value with the token % instead of the default | . To use the default token you can ommit the call to the method
`setMultiValueFieldToken`.
-``` java
+```java
new SolrFieldsMapper.Builder(
new RestJsonSchemaBuilder("localhost", "8983", "gettingstarted"), "gettingstarted")
.setMultiValueFieldToken("%").build();
@@ -115,8 +117,8 @@ and then generate an uber jar with all the dependencies.
Add the following to `REPO_HOME/storm/external/storm-solr/pom.xml`
- ```
- <plugin>
+```xml
+<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
@@ -140,11 +142,15 @@ and then generate an uber jar with all the dependencies.
create the uber jar by running the commmand:
-`mvn package -f REPO_HOME/storm/external/storm-solr/pom.xml`
+```
+mvn package -f REPO_HOME/storm/external/storm-solr/pom.xml
+```
This will create the uber jar file with the name and location matching the following pattern:
-`REPO_HOME/storm/external/storm/target/storm-solr-0.11.0-SNAPSHOT.jar`
+```
+REPO_HOME/storm/external/storm/target/storm-solr-0.11.0-SNAPSHOT.jar
+```
## Run Examples
Copy the file `REPO_HOME/storm/external/storm-solr/target/storm-solr-0.11.0-SNAPSHOT.jar` to `STORM_HOME/extlib`
[39/40] storm git commit: [STORM-2564] We should provide a template
for storm-cluster-auth.yaml
Posted by ka...@apache.org.
[STORM-2564] We should provide a template for storm-cluster-auth.yaml
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/9cfb1235
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/9cfb1235
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/9cfb1235
Branch: refs/heads/1.1.x-branch
Commit: 9cfb1235945590502bb5654f9ce12395484c0a50
Parents: 097a14b
Author: liuzhaokun <li...@zte.com.cn>
Authored: Wed Jun 21 13:24:32 2017 +0800
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 17:02:09 2017 +0900
----------------------------------------------------------------------
conf/storm-cluster-auth.yaml.example | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/9cfb1235/conf/storm-cluster-auth.yaml.example
----------------------------------------------------------------------
diff --git a/conf/storm-cluster-auth.yaml.example b/conf/storm-cluster-auth.yaml.example
new file mode 100644
index 0000000..9ed6a19
--- /dev/null
+++ b/conf/storm-cluster-auth.yaml.example
@@ -0,0 +1,18 @@
+# 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.
+
+########### Users should replace ${user} and ${pwd} with their own username and password
+#storm.zookeeper.auth.payload:${user}:${pwd}
\ No newline at end of file
[11/40] storm git commit: STORM-2448: Add in Storm and JDK versions
when submitting a topology
Posted by ka...@apache.org.
STORM-2448: Add in Storm and JDK versions when submitting a topology
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/3971337d
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/3971337d
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/3971337d
Branch: refs/heads/1.1.x-branch
Commit: 3971337d137a39664799616e45e8287f5facb67e
Parents: fe16fd4
Author: Robert (Bobby) Evans <ev...@yahoo-inc.com>
Authored: Tue Apr 4 12:34:49 2017 -0500
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:30:16 2017 +0900
----------------------------------------------------------------------
.../src/clj/org/apache/storm/daemon/common.clj | 34 ++-
.../src/clj/org/apache/storm/daemon/nimbus.clj | 4 +-
storm-core/src/clj/org/apache/storm/testing.clj | 4 +-
.../jvm/org/apache/storm/StormSubmitter.java | 2 +-
.../apache/storm/generated/StormTopology.java | 220 ++++++++++++++++++-
.../apache/storm/topology/TopologyBuilder.java | 2 +-
.../src/jvm/org/apache/storm/utils/Utils.java | 20 ++
storm-core/src/py/storm/ttypes.py | 28 ++-
storm-core/src/storm.thrift | 2 +
9 files changed, 287 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/3971337d/storm-core/src/clj/org/apache/storm/daemon/common.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/org/apache/storm/daemon/common.clj b/storm-core/src/clj/org/apache/storm/daemon/common.clj
index 20e03a0..db01727 100644
--- a/storm-core/src/clj/org/apache/storm/daemon/common.clj
+++ b/storm-core/src/clj/org/apache/storm/daemon/common.clj
@@ -121,32 +121,28 @@
)))))
(defn- validate-ids! [^StormTopology topology]
- (let [sets (map #(.getFieldValue topology %) thrift/STORM-TOPOLOGY-FIELDS)
+ (let [sets [(.get_bolts topology) (.get_spouts topology) (.get_state_spouts topology)]
offending (apply any-intersection sets)]
(if-not (empty? offending)
(throw (InvalidTopologyException.
(str "Duplicate component ids: " offending))))
- (doseq [f thrift/STORM-TOPOLOGY-FIELDS
- :let [obj-map (.getFieldValue topology f)]]
- (if-not (or (ThriftTopologyUtils/isWorkerHook f)
- (ThriftTopologyUtils/isDependencies f))
- (do
- (doseq [id (keys obj-map)]
- (if (Utils/isSystemId id)
- (throw (InvalidTopologyException.
- (str id " is not a valid component id")))))
- (doseq [obj (vals obj-map)
- id (-> obj .get_common .get_streams keys)]
- (if (Utils/isSystemId id)
- (throw (InvalidTopologyException.
- (str id " is not a valid stream id"))))))))))
+ (doseq [obj-map sets]
+ (do
+ (doseq [id (keys obj-map)]
+ (if (Utils/isSystemId id)
+ (throw (InvalidTopologyException.
+ (str id " is not a valid component id")))))
+ (doseq [obj (vals obj-map)
+ id (-> obj .get_common .get_streams keys)]
+ (if (Utils/isSystemId id)
+ (throw (InvalidTopologyException.
+ (str id " is not a valid stream id")))))))))
(defn all-components [^StormTopology topology]
(apply merge {}
- (for [f thrift/STORM-TOPOLOGY-FIELDS]
- (if-not (or (ThriftTopologyUtils/isWorkerHook f)
- (ThriftTopologyUtils/isDependencies f))
- (.getFieldValue topology f)))))
+ (.get_bolts topology)
+ (.get_spouts topology)
+ (.get_state_spouts topology)))
(defn component-conf [component]
(->> component
http://git-wip-us.apache.org/repos/asf/storm/blob/3971337d/storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/org/apache/storm/daemon/nimbus.clj b/storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
index f3b3373..3bd8a17 100644
--- a/storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
+++ b/storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
@@ -1698,7 +1698,9 @@
(throw (IllegalArgumentException. "The cluster is configured for zookeeper authentication, but no payload was provided.")))
(log-message "Received topology submission for "
storm-name
- " with conf "
+ " (storm-" (.get_storm_version topology)
+ " JDK-" (.get_jdk_version topology)
+ ") with conf "
(redact-value storm-conf STORM-ZOOKEEPER-TOPOLOGY-AUTH-PAYLOAD))
;; lock protects against multiple topologies being submitted at once and
;; cleanup thread killing topology in b/w assignment and starting the topology
http://git-wip-us.apache.org/repos/asf/storm/blob/3971337d/storm-core/src/clj/org/apache/storm/testing.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/org/apache/storm/testing.clj b/storm-core/src/clj/org/apache/storm/testing.clj
index c061922..db6b94b 100644
--- a/storm-core/src/clj/org/apache/storm/testing.clj
+++ b/storm-core/src/clj/org/apache/storm/testing.clj
@@ -307,13 +307,13 @@
[nimbus storm-name conf topology]
(when-not (Utils/isValidConf conf)
(throw (IllegalArgumentException. "Topology conf is not json-serializable")))
- (.submitTopology nimbus storm-name nil (to-json conf) topology))
+ (.submitTopology nimbus storm-name nil (to-json conf) (Utils/addVersions topology)))
(defn submit-local-topology-with-opts
[nimbus storm-name conf topology submit-opts]
(when-not (Utils/isValidConf conf)
(throw (IllegalArgumentException. "Topology conf is not json-serializable")))
- (.submitTopologyWithOpts nimbus storm-name nil (to-json conf) topology submit-opts))
+ (.submitTopologyWithOpts nimbus storm-name nil (to-json conf) (Utils/addVersions topology) submit-opts))
(defn mocked-convert-assignments-to-worker->resources [storm-cluster-state storm-name worker->resources]
(fn [existing-assignments]
http://git-wip-us.apache.org/repos/asf/storm/blob/3971337d/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/StormSubmitter.java b/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
index d382dd9..eeb90c5 100644
--- a/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
+++ b/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
@@ -321,7 +321,7 @@ public class StormSubmitter {
try {
String jar = submitJarAs(conf, System.getProperty("storm.jar"), progressListener, client);
LOG.info("Submitting topology {} in distributed mode with conf {}", name, serConf);
-
+ Utils.addVersions(topology);
if (opts != null) {
client.getClient().submitTopologyWithOpts(name, jar, serConf, topology, opts);
} else {
http://git-wip-us.apache.org/repos/asf/storm/blob/3971337d/storm-core/src/jvm/org/apache/storm/generated/StormTopology.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/generated/StormTopology.java b/storm-core/src/jvm/org/apache/storm/generated/StormTopology.java
index caec6c6..6241d7b 100644
--- a/storm-core/src/jvm/org/apache/storm/generated/StormTopology.java
+++ b/storm-core/src/jvm/org/apache/storm/generated/StormTopology.java
@@ -61,6 +61,8 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
private static final org.apache.thrift.protocol.TField WORKER_HOOKS_FIELD_DESC = new org.apache.thrift.protocol.TField("worker_hooks", org.apache.thrift.protocol.TType.LIST, (short)4);
private static final org.apache.thrift.protocol.TField DEPENDENCY_JARS_FIELD_DESC = new org.apache.thrift.protocol.TField("dependency_jars", org.apache.thrift.protocol.TType.LIST, (short)5);
private static final org.apache.thrift.protocol.TField DEPENDENCY_ARTIFACTS_FIELD_DESC = new org.apache.thrift.protocol.TField("dependency_artifacts", org.apache.thrift.protocol.TType.LIST, (short)6);
+ private static final org.apache.thrift.protocol.TField STORM_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("storm_version", org.apache.thrift.protocol.TType.STRING, (short)7);
+ private static final org.apache.thrift.protocol.TField JDK_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("jdk_version", org.apache.thrift.protocol.TType.STRING, (short)8);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@@ -74,6 +76,8 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
private List<ByteBuffer> worker_hooks; // optional
private List<String> dependency_jars; // optional
private List<String> dependency_artifacts; // optional
+ private String storm_version; // optional
+ private String jdk_version; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
@@ -82,7 +86,9 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
STATE_SPOUTS((short)3, "state_spouts"),
WORKER_HOOKS((short)4, "worker_hooks"),
DEPENDENCY_JARS((short)5, "dependency_jars"),
- DEPENDENCY_ARTIFACTS((short)6, "dependency_artifacts");
+ DEPENDENCY_ARTIFACTS((short)6, "dependency_artifacts"),
+ STORM_VERSION((short)7, "storm_version"),
+ JDK_VERSION((short)8, "jdk_version");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@@ -109,6 +115,10 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
return DEPENDENCY_JARS;
case 6: // DEPENDENCY_ARTIFACTS
return DEPENDENCY_ARTIFACTS;
+ case 7: // STORM_VERSION
+ return STORM_VERSION;
+ case 8: // JDK_VERSION
+ return JDK_VERSION;
default:
return null;
}
@@ -149,7 +159,7 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
}
// isset id assignments
- private static final _Fields optionals[] = {_Fields.WORKER_HOOKS,_Fields.DEPENDENCY_JARS,_Fields.DEPENDENCY_ARTIFACTS};
+ private static final _Fields optionals[] = {_Fields.WORKER_HOOKS,_Fields.DEPENDENCY_JARS,_Fields.DEPENDENCY_ARTIFACTS,_Fields.STORM_VERSION,_Fields.JDK_VERSION};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
@@ -174,6 +184,10 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
tmpMap.put(_Fields.DEPENDENCY_ARTIFACTS, new org.apache.thrift.meta_data.FieldMetaData("dependency_artifacts", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
+ tmpMap.put(_Fields.STORM_VERSION, new org.apache.thrift.meta_data.FieldMetaData("storm_version", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ tmpMap.put(_Fields.JDK_VERSION, new org.apache.thrift.meta_data.FieldMetaData("jdk_version", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(StormTopology.class, metaDataMap);
}
@@ -253,6 +267,12 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
List<String> __this__dependency_artifacts = new ArrayList<String>(other.dependency_artifacts);
this.dependency_artifacts = __this__dependency_artifacts;
}
+ if (other.is_set_storm_version()) {
+ this.storm_version = other.storm_version;
+ }
+ if (other.is_set_jdk_version()) {
+ this.jdk_version = other.jdk_version;
+ }
}
public StormTopology deepCopy() {
@@ -267,6 +287,8 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
this.worker_hooks = null;
this.dependency_jars = null;
this.dependency_artifacts = null;
+ this.storm_version = null;
+ this.jdk_version = null;
}
public int get_spouts_size() {
@@ -485,6 +507,52 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
}
}
+ public String get_storm_version() {
+ return this.storm_version;
+ }
+
+ public void set_storm_version(String storm_version) {
+ this.storm_version = storm_version;
+ }
+
+ public void unset_storm_version() {
+ this.storm_version = null;
+ }
+
+ /** Returns true if field storm_version is set (has been assigned a value) and false otherwise */
+ public boolean is_set_storm_version() {
+ return this.storm_version != null;
+ }
+
+ public void set_storm_version_isSet(boolean value) {
+ if (!value) {
+ this.storm_version = null;
+ }
+ }
+
+ public String get_jdk_version() {
+ return this.jdk_version;
+ }
+
+ public void set_jdk_version(String jdk_version) {
+ this.jdk_version = jdk_version;
+ }
+
+ public void unset_jdk_version() {
+ this.jdk_version = null;
+ }
+
+ /** Returns true if field jdk_version is set (has been assigned a value) and false otherwise */
+ public boolean is_set_jdk_version() {
+ return this.jdk_version != null;
+ }
+
+ public void set_jdk_version_isSet(boolean value) {
+ if (!value) {
+ this.jdk_version = null;
+ }
+ }
+
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SPOUTS:
@@ -535,6 +603,22 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
}
break;
+ case STORM_VERSION:
+ if (value == null) {
+ unset_storm_version();
+ } else {
+ set_storm_version((String)value);
+ }
+ break;
+
+ case JDK_VERSION:
+ if (value == null) {
+ unset_jdk_version();
+ } else {
+ set_jdk_version((String)value);
+ }
+ break;
+
}
}
@@ -558,6 +642,12 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
case DEPENDENCY_ARTIFACTS:
return get_dependency_artifacts();
+ case STORM_VERSION:
+ return get_storm_version();
+
+ case JDK_VERSION:
+ return get_jdk_version();
+
}
throw new IllegalStateException();
}
@@ -581,6 +671,10 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
return is_set_dependency_jars();
case DEPENDENCY_ARTIFACTS:
return is_set_dependency_artifacts();
+ case STORM_VERSION:
+ return is_set_storm_version();
+ case JDK_VERSION:
+ return is_set_jdk_version();
}
throw new IllegalStateException();
}
@@ -652,6 +746,24 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
return false;
}
+ boolean this_present_storm_version = true && this.is_set_storm_version();
+ boolean that_present_storm_version = true && that.is_set_storm_version();
+ if (this_present_storm_version || that_present_storm_version) {
+ if (!(this_present_storm_version && that_present_storm_version))
+ return false;
+ if (!this.storm_version.equals(that.storm_version))
+ return false;
+ }
+
+ boolean this_present_jdk_version = true && this.is_set_jdk_version();
+ boolean that_present_jdk_version = true && that.is_set_jdk_version();
+ if (this_present_jdk_version || that_present_jdk_version) {
+ if (!(this_present_jdk_version && that_present_jdk_version))
+ return false;
+ if (!this.jdk_version.equals(that.jdk_version))
+ return false;
+ }
+
return true;
}
@@ -689,6 +801,16 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
if (present_dependency_artifacts)
list.add(dependency_artifacts);
+ boolean present_storm_version = true && (is_set_storm_version());
+ list.add(present_storm_version);
+ if (present_storm_version)
+ list.add(storm_version);
+
+ boolean present_jdk_version = true && (is_set_jdk_version());
+ list.add(present_jdk_version);
+ if (present_jdk_version)
+ list.add(jdk_version);
+
return list.hashCode();
}
@@ -760,6 +882,26 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
return lastComparison;
}
}
+ lastComparison = Boolean.valueOf(is_set_storm_version()).compareTo(other.is_set_storm_version());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (is_set_storm_version()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.storm_version, other.storm_version);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(is_set_jdk_version()).compareTo(other.is_set_jdk_version());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (is_set_jdk_version()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.jdk_version, other.jdk_version);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
return 0;
}
@@ -833,6 +975,26 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
}
first = false;
}
+ if (is_set_storm_version()) {
+ if (!first) sb.append(", ");
+ sb.append("storm_version:");
+ if (this.storm_version == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.storm_version);
+ }
+ first = false;
+ }
+ if (is_set_jdk_version()) {
+ if (!first) sb.append(", ");
+ sb.append("jdk_version:");
+ if (this.jdk_version == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.jdk_version);
+ }
+ first = false;
+ }
sb.append(")");
return sb.toString();
}
@@ -1005,6 +1167,22 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
+ case 7: // STORM_VERSION
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.storm_version = iprot.readString();
+ struct.set_storm_version_isSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 8: // JDK_VERSION
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.jdk_version = iprot.readString();
+ struct.set_jdk_version_isSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@@ -1099,6 +1277,20 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
oprot.writeFieldEnd();
}
}
+ if (struct.storm_version != null) {
+ if (struct.is_set_storm_version()) {
+ oprot.writeFieldBegin(STORM_VERSION_FIELD_DESC);
+ oprot.writeString(struct.storm_version);
+ oprot.writeFieldEnd();
+ }
+ }
+ if (struct.jdk_version != null) {
+ if (struct.is_set_jdk_version()) {
+ oprot.writeFieldBegin(JDK_VERSION_FIELD_DESC);
+ oprot.writeString(struct.jdk_version);
+ oprot.writeFieldEnd();
+ }
+ }
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@@ -1150,7 +1342,13 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
if (struct.is_set_dependency_artifacts()) {
optionals.set(2);
}
- oprot.writeBitSet(optionals, 3);
+ if (struct.is_set_storm_version()) {
+ optionals.set(3);
+ }
+ if (struct.is_set_jdk_version()) {
+ optionals.set(4);
+ }
+ oprot.writeBitSet(optionals, 5);
if (struct.is_set_worker_hooks()) {
{
oprot.writeI32(struct.worker_hooks.size());
@@ -1178,6 +1376,12 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
}
}
}
+ if (struct.is_set_storm_version()) {
+ oprot.writeString(struct.storm_version);
+ }
+ if (struct.is_set_jdk_version()) {
+ oprot.writeString(struct.jdk_version);
+ }
}
@Override
@@ -1225,7 +1429,7 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
}
}
struct.set_state_spouts_isSet(true);
- BitSet incoming = iprot.readBitSet(3);
+ BitSet incoming = iprot.readBitSet(5);
if (incoming.get(0)) {
{
org.apache.thrift.protocol.TList _list89 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
@@ -1265,6 +1469,14 @@ public class StormTopology implements org.apache.thrift.TBase<StormTopology, Sto
}
struct.set_dependency_artifacts_isSet(true);
}
+ if (incoming.get(3)) {
+ struct.storm_version = iprot.readString();
+ struct.set_storm_version_isSet(true);
+ }
+ if (incoming.get(4)) {
+ struct.jdk_version = iprot.readString();
+ struct.set_jdk_version_isSet(true);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/storm/blob/3971337d/storm-core/src/jvm/org/apache/storm/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/topology/TopologyBuilder.java b/storm-core/src/jvm/org/apache/storm/topology/TopologyBuilder.java
index 40ede4c..ea4488b 100644
--- a/storm-core/src/jvm/org/apache/storm/topology/TopologyBuilder.java
+++ b/storm-core/src/jvm/org/apache/storm/topology/TopologyBuilder.java
@@ -153,7 +153,7 @@ public class TopologyBuilder {
stormTopology.set_worker_hooks(_workerHooks);
- return stormTopology;
+ return Utils.addVersions(stormTopology);
}
/**
http://git-wip-us.apache.org/repos/asf/storm/blob/3971337d/storm-core/src/jvm/org/apache/storm/utils/Utils.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/utils/Utils.java b/storm-core/src/jvm/org/apache/storm/utils/Utils.java
index 1a13a6f..b9ced2c 100644
--- a/storm-core/src/jvm/org/apache/storm/utils/Utils.java
+++ b/storm-core/src/jvm/org/apache/storm/utils/Utils.java
@@ -2271,4 +2271,24 @@ public class Utils {
return ret;
}
+ /**
+ * Add version information to the given topology
+ * @param topology the topology being submitted (MIGHT BE MODIFIED)
+ * @return topology
+ */
+ public static StormTopology addVersions(StormTopology topology) {
+ String stormVersion = VersionInfo.getVersion();
+ LOG.warn("STORM-VERSION new {} old {}", stormVersion, topology.get_storm_version());
+ if (stormVersion != null &&
+ !"Unknown".equalsIgnoreCase(stormVersion) &&
+ !topology.is_set_storm_version()) {
+ topology.set_storm_version(stormVersion);
+ }
+
+ String jdkVersion = System.getProperty("java.version");
+ if (jdkVersion != null && !topology.is_set_jdk_version()) {
+ topology.set_jdk_version(jdkVersion);
+ }
+ return topology;
+ }
}
http://git-wip-us.apache.org/repos/asf/storm/blob/3971337d/storm-core/src/py/storm/ttypes.py
----------------------------------------------------------------------
diff --git a/storm-core/src/py/storm/ttypes.py b/storm-core/src/py/storm/ttypes.py
index 4fac146..8262285 100644
--- a/storm-core/src/py/storm/ttypes.py
+++ b/storm-core/src/py/storm/ttypes.py
@@ -1394,6 +1394,8 @@ class StormTopology:
- worker_hooks
- dependency_jars
- dependency_artifacts
+ - storm_version
+ - jdk_version
"""
thrift_spec = (
@@ -1404,15 +1406,19 @@ class StormTopology:
(4, TType.LIST, 'worker_hooks', (TType.STRING,None), None, ), # 4
(5, TType.LIST, 'dependency_jars', (TType.STRING,None), None, ), # 5
(6, TType.LIST, 'dependency_artifacts', (TType.STRING,None), None, ), # 6
+ (7, TType.STRING, 'storm_version', None, None, ), # 7
+ (8, TType.STRING, 'jdk_version', None, None, ), # 8
)
- def __init__(self, spouts=None, bolts=None, state_spouts=None, worker_hooks=None, dependency_jars=None, dependency_artifacts=None,):
+ def __init__(self, spouts=None, bolts=None, state_spouts=None, worker_hooks=None, dependency_jars=None, dependency_artifacts=None, storm_version=None, jdk_version=None,):
self.spouts = spouts
self.bolts = bolts
self.state_spouts = state_spouts
self.worker_hooks = worker_hooks
self.dependency_jars = dependency_jars
self.dependency_artifacts = dependency_artifacts
+ self.storm_version = storm_version
+ self.jdk_version = jdk_version
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
@@ -1489,6 +1495,16 @@ class StormTopology:
iprot.readListEnd()
else:
iprot.skip(ftype)
+ elif fid == 7:
+ if ftype == TType.STRING:
+ self.storm_version = iprot.readString().decode('utf-8')
+ else:
+ iprot.skip(ftype)
+ elif fid == 8:
+ if ftype == TType.STRING:
+ self.jdk_version = iprot.readString().decode('utf-8')
+ else:
+ iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
@@ -1544,6 +1560,14 @@ class StormTopology:
oprot.writeString(iter86.encode('utf-8'))
oprot.writeListEnd()
oprot.writeFieldEnd()
+ if self.storm_version is not None:
+ oprot.writeFieldBegin('storm_version', TType.STRING, 7)
+ oprot.writeString(self.storm_version.encode('utf-8'))
+ oprot.writeFieldEnd()
+ if self.jdk_version is not None:
+ oprot.writeFieldBegin('jdk_version', TType.STRING, 8)
+ oprot.writeString(self.jdk_version.encode('utf-8'))
+ oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
@@ -1565,6 +1589,8 @@ class StormTopology:
value = (value * 31) ^ hash(self.worker_hooks)
value = (value * 31) ^ hash(self.dependency_jars)
value = (value * 31) ^ hash(self.dependency_artifacts)
+ value = (value * 31) ^ hash(self.storm_version)
+ value = (value * 31) ^ hash(self.jdk_version)
return value
def __repr__(self):
http://git-wip-us.apache.org/repos/asf/storm/blob/3971337d/storm-core/src/storm.thrift
----------------------------------------------------------------------
diff --git a/storm-core/src/storm.thrift b/storm-core/src/storm.thrift
index 700e5a0..146591f 100644
--- a/storm-core/src/storm.thrift
+++ b/storm-core/src/storm.thrift
@@ -120,6 +120,8 @@ struct StormTopology {
4: optional list<binary> worker_hooks;
5: optional list<string> dependency_jars;
6: optional list<string> dependency_artifacts;
+ 7: optional string storm_version;
+ 8: optional string jdk_version;
}
exception AlreadyAliveException {
[13/40] storm git commit: STORM-1114: Handle race condition in
Storm/Trident transactional state when ZK nodes have already been
created/deleted
Posted by ka...@apache.org.
STORM-1114: Handle race condition in Storm/Trident transactional state when ZK nodes have already been created/deleted
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/d8870362
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/d8870362
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/d8870362
Branch: refs/heads/1.1.x-branch
Commit: d887036220dfbf9af3ca30e3bcc04ccc57170139
Parents: 06932d6
Author: P. Taylor Goetz <pt...@gmail.com>
Authored: Thu Apr 13 15:08:16 2017 -0400
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:32:00 2017 +0900
----------------------------------------------------------------------
.../apache/storm/transactional/state/TransactionalState.java | 7 +++++++
.../storm/trident/topology/state/TransactionalState.java | 7 +++++--
2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/d8870362/storm-core/src/jvm/org/apache/storm/transactional/state/TransactionalState.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/transactional/state/TransactionalState.java b/storm-core/src/jvm/org/apache/storm/transactional/state/TransactionalState.java
index f05512e..7662daa 100644
--- a/storm-core/src/jvm/org/apache/storm/transactional/state/TransactionalState.java
+++ b/storm-core/src/jvm/org/apache/storm/transactional/state/TransactionalState.java
@@ -34,8 +34,11 @@ import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Id;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TransactionalState {
+ private static final Logger LOG = LoggerFactory.getLogger(TransactionalState.class);
CuratorFramework _curator;
KryoValuesSerializer _ser;
KryoValuesDeserializer _des;
@@ -117,6 +120,8 @@ public class TransactionalState {
TransactionalState.createNode(_curator, path, ser, _zkAcls,
CreateMode.PERSISTENT);
}
+ } catch (KeeperException.NodeExistsException nne){
+ LOG.warn("Node {} already created.", path);
} catch(Exception e) {
throw new RuntimeException(e);
}
@@ -126,6 +131,8 @@ public class TransactionalState {
path = "/" + path;
try {
_curator.delete().forPath(path);
+ } catch (KeeperException.NoNodeException nne){
+ LOG.warn("Path {} already deleted.");
} catch (Exception e) {
throw new RuntimeException(e);
}
http://git-wip-us.apache.org/repos/asf/storm/blob/d8870362/storm-core/src/jvm/org/apache/storm/trident/topology/state/TransactionalState.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/trident/topology/state/TransactionalState.java b/storm-core/src/jvm/org/apache/storm/trident/topology/state/TransactionalState.java
index 26ac404..71068dc 100644
--- a/storm-core/src/jvm/org/apache/storm/trident/topology/state/TransactionalState.java
+++ b/storm-core/src/jvm/org/apache/storm/trident/topology/state/TransactionalState.java
@@ -125,16 +125,19 @@ public class TransactionalState {
TransactionalState.createNode(_curator, path, ser, _zkAcls,
CreateMode.PERSISTENT);
}
- LOG.debug("Set [path = {}] => [data = {}]", path, asString(ser));
+ } catch (KeeperException.NodeExistsException nne){
+ LOG.warn("Node {} already created.", path);
} catch(Exception e) {
throw new RuntimeException(e);
- }
+ }
}
public void delete(String path) {
path = "/" + path;
try {
_curator.delete().forPath(path);
+ } catch (KeeperException.NoNodeException nne){
+ LOG.warn("Path {} already deleted.");
} catch (Exception e) {
throw new RuntimeException(e);
}
[22/40] storm git commit: STORM-2496 Dependency artifacts should be
uploaded to blobstore with READ permission for all
Posted by ka...@apache.org.
STORM-2496 Dependency artifacts should be uploaded to blobstore with READ permission for all
* When uploading dependencies, set ACL properly so that it can be shared to other users as well
* but allows only READ so that it can't be deleted from others
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/796e7156
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/796e7156
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/796e7156
Branch: refs/heads/1.1.x-branch
Commit: 796e7156480d07b6c1cd52a7f3588239e2bfdc73
Parents: a265929
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Mon May 8 12:14:25 2017 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:43:44 2017 +0900
----------------------------------------------------------------------
.../apache/storm/dependency/DependencyUploader.java | 13 ++++++++++---
.../storm/dependency/DependencyUploaderTest.java | 15 ++++++++++++++-
2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/796e7156/storm-core/src/jvm/org/apache/storm/dependency/DependencyUploader.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/dependency/DependencyUploader.java b/storm-core/src/jvm/org/apache/storm/dependency/DependencyUploader.java
index 636f454..16a3f61 100644
--- a/storm-core/src/jvm/org/apache/storm/dependency/DependencyUploader.java
+++ b/storm-core/src/jvm/org/apache/storm/dependency/DependencyUploader.java
@@ -20,8 +20,10 @@ package org.apache.storm.dependency;
import com.google.common.annotations.VisibleForTesting;
import org.apache.storm.blobstore.AtomicOutputStream;
import org.apache.storm.blobstore.BlobStoreUtils;
+import org.apache.storm.blobstore.BlobStoreAclHandler;
import org.apache.storm.blobstore.ClientBlobStore;
import org.apache.storm.generated.AccessControl;
+import org.apache.storm.generated.AccessControlType;
import org.apache.storm.generated.AuthorizationException;
import org.apache.storm.generated.KeyAlreadyExistsException;
import org.apache.storm.generated.KeyNotFoundException;
@@ -146,9 +148,14 @@ public class DependencyUploader {
// as a workaround, we call getBlobMeta() for all keys
getBlobStore().getBlobMeta(key);
} catch (KeyNotFoundException e) {
- // TODO: do we want to add ACL here?
- AtomicOutputStream blob = getBlobStore()
- .createBlob(key, new SettableBlobMeta(new ArrayList<AccessControl>()));
+ // set acl to below so that it can be shared by other users as well, but allows only read
+ List<AccessControl> acls = new ArrayList<>();
+ acls.add(new AccessControl(AccessControlType.USER,
+ BlobStoreAclHandler.READ | BlobStoreAclHandler.WRITE | BlobStoreAclHandler.ADMIN));
+ acls.add(new AccessControl(AccessControlType.OTHER,
+ BlobStoreAclHandler.READ));
+
+ AtomicOutputStream blob = getBlobStore().createBlob(key, new SettableBlobMeta(acls));
Files.copy(dependency.toPath(), blob);
blob.close();
http://git-wip-us.apache.org/repos/asf/storm/blob/796e7156/storm-core/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java b/storm-core/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java
index 526e758..e5d9faf 100644
--- a/storm-core/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java
+++ b/storm-core/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java
@@ -20,14 +20,17 @@ package org.apache.storm.dependency;
import com.google.common.collect.Lists;
import com.google.common.io.Files;
import org.apache.storm.blobstore.AtomicOutputStream;
-import org.apache.storm.blobstore.BlobStoreUtils;
+import org.apache.storm.blobstore.BlobStoreAclHandler;
import org.apache.storm.blobstore.ClientBlobStore;
+import org.apache.storm.generated.AccessControl;
+import org.apache.storm.generated.AccessControlType;
import org.apache.storm.generated.KeyNotFoundException;
import org.apache.storm.generated.ReadableBlobMeta;
import org.apache.storm.generated.SettableBlobMeta;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -171,6 +174,16 @@ public class DependencyUploaderTest {
assertTrue(counter.get() > 0);
verify(mockOutputStream).close();
+
+ ArgumentCaptor<SettableBlobMeta> blobMetaArgumentCaptor = ArgumentCaptor.forClass(SettableBlobMeta.class);
+ verify(mockBlobStore).createBlob(anyString(), blobMetaArgumentCaptor.capture());
+
+ SettableBlobMeta actualBlobMeta = blobMetaArgumentCaptor.getValue();
+ List<AccessControl> actualAcls = actualBlobMeta.get_acl();
+ assertTrue(actualAcls.contains(new AccessControl(AccessControlType.USER,
+ BlobStoreAclHandler.READ | BlobStoreAclHandler.WRITE | BlobStoreAclHandler.ADMIN)));
+ assertTrue(actualAcls.contains(new AccessControl(AccessControlType.OTHER,
+ BlobStoreAclHandler.READ)));
}
@Test(expected = FileNotAvailableException.class)
[35/40] storm git commit: STORM-2562: Use stronger key size than
default for blow fish key generator and get rid of stack trace
Posted by ka...@apache.org.
STORM-2562: Use stronger key size than default for blow fish key generator and get rid of stack trace
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/654ad6cb
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/654ad6cb
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/654ad6cb
Branch: refs/heads/1.1.x-branch
Commit: 654ad6cbf2a177b302c40dd9ca540ae336b69e46
Parents: 4e834f1
Author: Priyank <ps...@hortonworks.com>
Authored: Tue Jun 20 12:01:13 2017 -0700
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:58:22 2017 +0900
----------------------------------------------------------------------
.../storm/security/serialization/BlowfishTupleSerializer.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/654ad6cb/storm-core/src/jvm/org/apache/storm/security/serialization/BlowfishTupleSerializer.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/security/serialization/BlowfishTupleSerializer.java b/storm-core/src/jvm/org/apache/storm/security/serialization/BlowfishTupleSerializer.java
index 8cc2f23..63788ce 100644
--- a/storm-core/src/jvm/org/apache/storm/security/serialization/BlowfishTupleSerializer.java
+++ b/storm-core/src/jvm/org/apache/storm/security/serialization/BlowfishTupleSerializer.java
@@ -80,13 +80,13 @@ public class BlowfishTupleSerializer extends Serializer<ListDelegate> {
public static void main(String[] args) {
try{
KeyGenerator kgen = KeyGenerator.getInstance("Blowfish");
+ kgen.init(256);
SecretKey skey = kgen.generateKey();
byte[] raw = skey.getEncoded();
String keyString = new String(Hex.encodeHex(raw));
System.out.println("storm -c "+SECRET_KEY+"="+keyString+" -c "+Config.TOPOLOGY_TUPLE_SERIALIZER+"="+BlowfishTupleSerializer.class.getName() + " ..." );
} catch (Exception ex) {
LOG.error(ex.getMessage());
- ex.printStackTrace();
}
}
}
[16/40] storm git commit: Fix headers
Posted by ka...@apache.org.
Fix headers
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/a3f2946a
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/a3f2946a
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/a3f2946a
Branch: refs/heads/1.1.x-branch
Commit: a3f2946a00cd0da37bd851a3a514077da2916b1b
Parents: 703afcf
Author: AZ <an...@izinenko.ru>
Authored: Fri Mar 24 12:56:08 2017 +0300
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:33:53 2017 +0900
----------------------------------------------------------------------
external/storm-kafka/README.md | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/a3f2946a/external/storm-kafka/README.md
----------------------------------------------------------------------
diff --git a/external/storm-kafka/README.md b/external/storm-kafka/README.md
index 5e86cce..3ba9b0c 100644
--- a/external/storm-kafka/README.md
+++ b/external/storm-kafka/README.md
@@ -3,15 +3,15 @@ Storm Kafka
Provides core Storm and Trident spout implementations for consuming data from Apache Kafka 0.8.x.
-##Spouts
+## Spouts
We support both Trident and core Storm spouts. For both spout implementations, we use a BrokerHost interface that
tracks Kafka broker host to partition mapping and kafkaConfig that controls some Kafka related parameters.
-###BrokerHosts
+### BrokerHosts
In order to initialize your Kafka spout/emitter you need to construct an instance of the marker interface BrokerHosts.
Currently, we support the following two implementations:
-####ZkHosts
+#### ZkHosts
ZkHosts is what you should use if you want to dynamically track Kafka broker to partition mapping. This class uses
Kafka's ZooKeeper entries to track brokerHost -> partition mapping. You can instantiate an object by calling
```java
@@ -24,7 +24,7 @@ partition information is stored. By default this is /brokers which is what the d
By default, the broker-partition mapping is refreshed every 60 seconds from ZooKeeper. If you want to change it, you
should set host.refreshFreqSecs to your chosen value.
-####StaticHosts
+#### StaticHosts
This is an alternative implementation where broker -> partition information is static. In order to construct an instance
of this class, you need to first construct an instance of GlobalPartitionInformation.
@@ -39,7 +39,7 @@ of this class, you need to first construct an instance of GlobalPartitionInforma
StaticHosts hosts = new StaticHosts(partitionInfo);
```
-###KafkaConfig
+### KafkaConfig
The second thing needed for constructing a kafkaSpout is an instance of KafkaConfig.
```java
public KafkaConfig(BrokerHosts hosts, String topic)
@@ -98,7 +98,7 @@ The KafkaConfig class also has bunch of public variables that controls your appl
```
Most of them are self explanatory except MultiScheme.
-###MultiScheme
+### MultiScheme
MultiScheme is an interface that dictates how the ByteBuffer consumed from Kafka gets transformed into a storm tuple. It
also controls the naming of your output field.
@@ -119,7 +119,7 @@ public Iterable<List<Object>> deserializeMessageWithMetadata(ByteBuffer message,
This is useful for auditing/replaying messages from arbitrary points on a Kafka topic, saving the partition and offset of each message of a discrete stream instead of persisting the entire message.
-###Failed message retry
+### Failed message retry
FailedMsgRetryManager is an interface which defines the retry strategy for a failed message. Default implementation is ExponentialBackoffMsgRetryManager which retries with exponential delays
between consecutive retries. To use a custom implementation, set SpoutConfig.failedMsgRetryManagerClass to the full classname
of implementation. Here is the interface
@@ -253,14 +253,14 @@ When selecting a kafka dependency version, you should ensure -
0.8.x broker.
-##Writing to Kafka as part of your topology
+## Writing to Kafka as part of your topology
You can create an instance of org.apache.storm.kafka.bolt.KafkaBolt and attach it as a component to your topology or if you
are using trident you can use org.apache.storm.kafka.trident.TridentState, org.apache.storm.kafka.trident.TridentStateFactory and
org.apache.storm.kafka.trident.TridentKafkaUpdater.
You need to provide implementation of following 2 interfaces
-###TupleToKafkaMapper and TridentTupleToKafkaMapper
+### TupleToKafkaMapper and TridentTupleToKafkaMapper
These interfaces have 2 methods defined:
```java
@@ -276,7 +276,7 @@ reasons. Alternatively you could also specify a different key and message field
In the TridentKafkaState you must specify what is the field name for key and message as there is no default constructor.
These should be specified while constructing and instance of FieldNameBasedTupleToKafkaMapper.
-###KafkaTopicSelector and trident KafkaTopicSelector
+### KafkaTopicSelector and trident KafkaTopicSelector
This interface has only one method
```java
public interface KafkaTopicSelector {
@@ -295,7 +295,7 @@ Please make sure the default topic have created .
You can provide all the produce properties in your Storm topology by calling `KafkaBolt.withProducerProperties()` and `TridentKafkaStateFactory.withProducerProperties()`. Please see http://kafka.apache.org/documentation.html#newproducerconfigs
Section "Important configuration properties for the producer" for more details.
-###Using wildcard kafka topic match
+### Using wildcard kafka topic match
You can do a wildcard topic match by adding the following config
```
Config config = new Config();
@@ -306,7 +306,7 @@ You can do a wildcard topic match by adding the following config
After this you can specify a wildcard topic for matching e.g. clickstream.*.log. This will match all streams matching clickstream.my.log, clickstream.cart.log etc
-###Putting it all together
+### Putting it all together
For the bolt :
```java
[34/40] storm git commit: STORM-2557: A bug in DisruptorQueue causing
severe underestimation of queue arrival rates
Posted by ka...@apache.org.
STORM-2557: A bug in DisruptorQueue causing severe underestimation of queue arrival rates
* create a method for counting number of tuples
* Closes #2164
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/4e834f1d
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/4e834f1d
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/4e834f1d
Branch: refs/heads/1.1.x-branch
Commit: 4e834f1d90bcec11ced29b5b8e70cd7f1e02971e
Parents: 819f917
Author: wendyshusband <tk...@126.com>
Authored: Sat Jun 17 13:40:17 2017 +0800
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:57:16 2017 +0900
----------------------------------------------------------------------
.../org/apache/storm/utils/DisruptorQueue.java | 24 ++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/4e834f1d/storm-core/src/jvm/org/apache/storm/utils/DisruptorQueue.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/utils/DisruptorQueue.java b/storm-core/src/jvm/org/apache/storm/utils/DisruptorQueue.java
index f2f202b..fe90240 100644
--- a/storm-core/src/jvm/org/apache/storm/utils/DisruptorQueue.java
+++ b/storm-core/src/jvm/org/apache/storm/utils/DisruptorQueue.java
@@ -496,8 +496,25 @@ public class DisruptorQueue implements IStatefulObject {
return Thread.currentThread().getId();
}
+ private long getTupleCount(Object obj) {
+ //a published object could be an instance of either AddressedTuple, ArrayList<AddressedTuple>, or HashMap<Integer, ArrayList<TaskMessage>>.
+ long tupleCount;
+ if (obj instanceof ArrayList) {
+ tupleCount = ((ArrayList) obj).size();
+ } else if (obj instanceof HashMap) {
+ tupleCount = 0;
+ for (Object value:((HashMap) obj).values()) {
+ tupleCount += ((ArrayList) value).size();
+ }
+ } else {
+ tupleCount = 1;
+ }
+ return tupleCount;
+ }
+
private void publishDirectSingle(Object obj, boolean block) throws InsufficientCapacityException {
long at;
+ long numberOfTuples;
if (block) {
at = _buffer.next();
} else {
@@ -506,7 +523,8 @@ public class DisruptorQueue implements IStatefulObject {
AtomicReference<Object> m = _buffer.get(at);
m.set(obj);
_buffer.publish(at);
- _metrics.notifyArrivals(1);
+ numberOfTuples = getTupleCount(obj);
+ _metrics.notifyArrivals(numberOfTuples);
}
private void publishDirect(ArrayList<Object> objs, boolean block) throws InsufficientCapacityException {
@@ -520,13 +538,15 @@ public class DisruptorQueue implements IStatefulObject {
}
long begin = end - (size - 1);
long at = begin;
+ long numberOfTuples = 0;
for (Object obj: objs) {
AtomicReference<Object> m = _buffer.get(at);
m.set(obj);
at++;
+ numberOfTuples += getTupleCount(obj);
}
_buffer.publish(begin, end);
- _metrics.notifyArrivals(size);
+ _metrics.notifyArrivals(numberOfTuples);
}
}
[30/40] storm git commit: STORM-2489: Overlap and data loss on
WindowedBolt based on Duration
Posted by ka...@apache.org.
STORM-2489: Overlap and data loss on WindowedBolt based on Duration
- Fixed time eviction to not evict events beyond current timestamp.
- Introduce a processing time delta for dynamically adjusting window boundaries
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/ce8081e9
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/ce8081e9
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/ce8081e9
Branch: refs/heads/1.1.x-branch
Commit: ce8081e9d1ebbac18d3de6b3802f21f2b0ea127c
Parents: a8fab3c
Author: Arun Mahadevan <ar...@apache.org>
Authored: Tue Apr 25 12:37:43 2017 +0530
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:55:16 2017 +0900
----------------------------------------------------------------------
.../storm/topology/WindowedBoltExecutor.java | 2 +-
.../storm/windowing/DefaultEvictionContext.java | 11 ++++++++
.../apache/storm/windowing/EvictionContext.java | 8 ++++++
.../storm/windowing/TimeEvictionPolicy.java | 27 +++++++++++++++++++-
.../storm/windowing/TimeTriggerPolicy.java | 4 ++-
5 files changed, 49 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/ce8081e9/storm-core/src/jvm/org/apache/storm/topology/WindowedBoltExecutor.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/topology/WindowedBoltExecutor.java b/storm-core/src/jvm/org/apache/storm/topology/WindowedBoltExecutor.java
index fd98274..965d11c 100644
--- a/storm-core/src/jvm/org/apache/storm/topology/WindowedBoltExecutor.java
+++ b/storm-core/src/jvm/org/apache/storm/topology/WindowedBoltExecutor.java
@@ -275,7 +275,7 @@ public class WindowedBoltExecutor implements IRichBolt {
this.listener = newWindowLifecycleListener();
this.windowManager = initWindowManager(listener, stormConf, context);
start();
- LOG.debug("Initialized window manager {} ", this.windowManager);
+ LOG.info("Initialized window manager {} ", windowManager);
}
@Override
http://git-wip-us.apache.org/repos/asf/storm/blob/ce8081e9/storm-core/src/jvm/org/apache/storm/windowing/DefaultEvictionContext.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/windowing/DefaultEvictionContext.java b/storm-core/src/jvm/org/apache/storm/windowing/DefaultEvictionContext.java
index ef65f66..cc16664 100644
--- a/storm-core/src/jvm/org/apache/storm/windowing/DefaultEvictionContext.java
+++ b/storm-core/src/jvm/org/apache/storm/windowing/DefaultEvictionContext.java
@@ -21,6 +21,7 @@ public class DefaultEvictionContext implements EvictionContext {
private final Long referenceTime;
private final Long currentCount;
private final Long slidingCount;
+ private final Long slidingInterval;
public DefaultEvictionContext(Long referenceTime) {
this(referenceTime, null);
@@ -31,9 +32,14 @@ public class DefaultEvictionContext implements EvictionContext {
}
public DefaultEvictionContext(Long referenceTime, Long currentCount, Long slidingCount) {
+ this(referenceTime, currentCount, slidingCount, null);
+ }
+
+ public DefaultEvictionContext(Long referenceTime, Long currentCount, Long slidingCount, Long slidingInterval) {
this.referenceTime = referenceTime;
this.currentCount = currentCount;
this.slidingCount = slidingCount;
+ this.slidingInterval = slidingInterval;
}
@Override
@@ -50,4 +56,9 @@ public class DefaultEvictionContext implements EvictionContext {
public Long getSlidingCount() {
return slidingCount;
}
+
+ @Override
+ public Long getSlidingInterval() {
+ return slidingInterval;
+ }
}
http://git-wip-us.apache.org/repos/asf/storm/blob/ce8081e9/storm-core/src/jvm/org/apache/storm/windowing/EvictionContext.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/windowing/EvictionContext.java b/storm-core/src/jvm/org/apache/storm/windowing/EvictionContext.java
index 37dcfd9..c5a578a 100644
--- a/storm-core/src/jvm/org/apache/storm/windowing/EvictionContext.java
+++ b/storm-core/src/jvm/org/apache/storm/windowing/EvictionContext.java
@@ -37,6 +37,14 @@ public interface EvictionContext {
*/
Long getSlidingCount();
+
+ /**
+ * Returns the sliding interval for time based windows
+ *
+ * @return the sliding interval
+ */
+ Long getSlidingInterval();
+
/**
* Returns the current count of events in the queue up to the reference tim
* based on which count based evictions can be performed.
http://git-wip-us.apache.org/repos/asf/storm/blob/ce8081e9/storm-core/src/jvm/org/apache/storm/windowing/TimeEvictionPolicy.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/windowing/TimeEvictionPolicy.java b/storm-core/src/jvm/org/apache/storm/windowing/TimeEvictionPolicy.java
index e646207..0ab28a1 100644
--- a/storm-core/src/jvm/org/apache/storm/windowing/TimeEvictionPolicy.java
+++ b/storm-core/src/jvm/org/apache/storm/windowing/TimeEvictionPolicy.java
@@ -17,16 +17,23 @@
*/
package org.apache.storm.windowing;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Eviction policy that evicts events based on time duration.
*/
public class TimeEvictionPolicy<T> implements EvictionPolicy<T> {
+ private static final Logger LOG = LoggerFactory.getLogger(TimeEvictionPolicy.class);
+
private final int windowLength;
/**
* The reference time in millis for window calculations and
* expiring events. If not set it will default to System.currentTimeMillis()
*/
protected Long referenceTime;
+ protected EvictionContext evictionContext;
+ private long delta;
/**
* Constructs a TimeEvictionPolicy that evicts events older
@@ -45,8 +52,10 @@ public class TimeEvictionPolicy<T> implements EvictionPolicy<T> {
public Action evict(Event<T> event) {
long now = referenceTime == null ? System.currentTimeMillis() : referenceTime;
long diff = now - event.getTimestamp();
- if (diff >= windowLength) {
+ if (diff >= (windowLength + delta)) {
return Action.EXPIRE;
+ } else if (diff < 0) { // do not process events beyond current ts
+ return Action.KEEP;
}
return Action.PROCESS;
}
@@ -59,6 +68,22 @@ public class TimeEvictionPolicy<T> implements EvictionPolicy<T> {
@Override
public void setContext(EvictionContext context) {
referenceTime = context.getReferenceTime();
+ EvictionContext prevContext = evictionContext;
+ evictionContext = context;
+ // compute window length adjustment (delta) to account for time drift
+ if (context.getSlidingInterval() != null) {
+ if (prevContext == null) {
+ delta = Integer.MAX_VALUE; // consider all events for the initial window
+ } else {
+ delta = context.getReferenceTime() - prevContext.getReferenceTime() - context.getSlidingInterval();
+ if (Math.abs(delta) > 100) {
+ LOG.warn("Possible clock drift or long running computation in window; " +
+ "Previous eviction time: {}, current eviction time: {}",
+ prevContext.getReferenceTime(),
+ context.getReferenceTime());
+ }
+ }
+ }
}
@Override
http://git-wip-us.apache.org/repos/asf/storm/blob/ce8081e9/storm-core/src/jvm/org/apache/storm/windowing/TimeTriggerPolicy.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/windowing/TimeTriggerPolicy.java b/storm-core/src/jvm/org/apache/storm/windowing/TimeTriggerPolicy.java
index b057afb..f6e0197 100644
--- a/storm-core/src/jvm/org/apache/storm/windowing/TimeTriggerPolicy.java
+++ b/storm-core/src/jvm/org/apache/storm/windowing/TimeTriggerPolicy.java
@@ -109,13 +109,15 @@ public class TimeTriggerPolicy<T> implements TriggerPolicy<T> {
return new Runnable() {
@Override
public void run() {
+ // do not process current timestamp since tuples might arrive while the trigger is executing
+ long now = System.currentTimeMillis() - 1;
try {
/*
* set the current timestamp as the reference time for the eviction policy
* to evict the events
*/
if (evictionPolicy != null) {
- evictionPolicy.setContext(new DefaultEvictionContext(System.currentTimeMillis()));
+ evictionPolicy.setContext(new DefaultEvictionContext(now, null, null, duration));
}
handler.onTrigger();
} catch (Throwable th) {
[33/40] storm git commit: STORM-2449 Ensure same key appears only
once in State iterator
Posted by ka...@apache.org.
STORM-2449 Ensure same key appears only once in State iterator
* also don't expose TOMBSTONE keys
* fix test to be compatible with JDK 7
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/819f9177
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/819f9177
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/819f9177
Branch: refs/heads/1.1.x-branch
Commit: 819f917739d0d15cb69218d2d5a7a333cc684362
Parents: 5832324
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Fri Jun 16 15:39:45 2017 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:56:49 2017 +0900
----------------------------------------------------------------------
.../redis/state/RedisKeyValueStateIterator.java | 131 ++++++---
.../state/RedisKeyValueStateIteratorTest.java | 264 +++++++++++++++++++
2 files changed, 360 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/819f9177/external/storm-redis/src/main/java/org/apache/storm/redis/state/RedisKeyValueStateIterator.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/main/java/org/apache/storm/redis/state/RedisKeyValueStateIterator.java b/external/storm-redis/src/main/java/org/apache/storm/redis/state/RedisKeyValueStateIterator.java
index d3f9d2f..748e852 100644
--- a/external/storm-redis/src/main/java/org/apache/storm/redis/state/RedisKeyValueStateIterator.java
+++ b/external/storm-redis/src/main/java/org/apache/storm/redis/state/RedisKeyValueStateIterator.java
@@ -15,19 +15,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.storm.redis.state;
-import com.google.common.base.Optional;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.PeekingIterator;
import java.util.AbstractMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
+import java.util.Set;
import org.apache.storm.redis.common.container.JedisCommandsInstanceContainer;
import org.apache.storm.redis.utils.RedisEncoder;
-import org.apache.storm.state.DefaultStateSerializer;
import org.apache.storm.state.Serializer;
import redis.clients.jedis.JedisCommands;
@@ -35,43 +38,82 @@ import redis.clients.jedis.ScanParams;
import redis.clients.jedis.ScanResult;
/**
- * An iterator over {@link RedisKeyValueState}
+ * An iterator over {@link RedisKeyValueState}.
*/
public class RedisKeyValueStateIterator<K, V> implements Iterator<Map.Entry<K, V>> {
private final String namespace;
- private final Iterator<Map.Entry<String, String>> pendingPrepareIterator;
- private final Iterator<Map.Entry<String, String>> pendingCommitIterator;
+ private final PeekingIterator<Map.Entry<String, String>> pendingPrepareIterator;
+ private final PeekingIterator<Map.Entry<String, String>> pendingCommitIterator;
private final RedisEncoder<K, V> decoder;
private final JedisCommandsInstanceContainer jedisContainer;
private final ScanParams scanParams;
- private Iterator<Map.Entry<String, String>> pendingIterator;
+ private final Set<String> providedKeys;
+
+ private PeekingIterator<Map.Entry<String, String>> cachedResultIterator;
private String cursor;
- private List<Map.Entry<String, String>> cachedResult;
- private int readPosition;
+ private boolean firstLoad = true;
+ private PeekingIterator<Map.Entry<String, String>> pendingIterator;
- public RedisKeyValueStateIterator(String namespace, JedisCommandsInstanceContainer jedisContainer, Iterator<Map.Entry<String, String>> pendingPrepareIterator, Iterator<Map.Entry<String, String>> pendingCommitIterator, int chunkSize, Serializer<K> keySerializer, Serializer<V> valueSerializer) {
+ /**
+ * Constructor.
+ *
+ * @param namespace The namespace of State
+ * @param jedisContainer The instance of JedisContainter
+ * @param pendingPrepareIterator The iterator of pendingPrepare
+ * @param pendingCommitIterator The iterator of pendingCommit
+ * @param chunkSize The size of chunk to get entries from Redis
+ * @param keySerializer The serializer of key
+ * @param valueSerializer The serializer of value
+ */
+ public RedisKeyValueStateIterator(String namespace, JedisCommandsInstanceContainer jedisContainer,
+ Iterator<Map.Entry<String, String>> pendingPrepareIterator,
+ Iterator<Map.Entry<String, String>> pendingCommitIterator,
+ int chunkSize, Serializer<K> keySerializer,
+ Serializer<V> valueSerializer) {
this.namespace = namespace;
- this.pendingPrepareIterator = pendingPrepareIterator;
- this.pendingCommitIterator = pendingCommitIterator;
+ this.pendingPrepareIterator = Iterators.peekingIterator(pendingPrepareIterator);
+ this.pendingCommitIterator = Iterators.peekingIterator(pendingCommitIterator);
this.jedisContainer = jedisContainer;
this.decoder = new RedisEncoder<K, V>(keySerializer, valueSerializer);
this.scanParams = new ScanParams().count(chunkSize);
this.cursor = ScanParams.SCAN_POINTER_START;
+ this.providedKeys = new HashSet<>();
}
@Override
public boolean hasNext() {
- if (pendingPrepareIterator != null && pendingPrepareIterator.hasNext()) {
+ if (seekToAvailableEntry(pendingPrepareIterator)) {
pendingIterator = pendingPrepareIterator;
return true;
- } else if (pendingCommitIterator != null && pendingCommitIterator.hasNext()) {
+ }
+
+ if (seekToAvailableEntry(pendingCommitIterator)) {
pendingIterator = pendingCommitIterator;
return true;
- } else {
- pendingIterator = null;
- return !cursor.equals("0");
}
+
+ if (firstLoad) {
+ // load the first part of entries
+ loadChunkFromRedis();
+ firstLoad = false;
+ }
+
+ while (true) {
+ if (seekToAvailableEntry(cachedResultIterator)) {
+ pendingIterator = cachedResultIterator;
+ return true;
+ }
+
+ if (cursor.equals(ScanParams.SCAN_POINTER_START)) {
+ break;
+ }
+
+ loadChunkFromRedis();
+ }
+
+ pendingIterator = null;
+ return false;
}
@Override
@@ -79,27 +121,11 @@ public class RedisKeyValueStateIterator<K, V> implements Iterator<Map.Entry<K, V
if (!hasNext()) {
throw new NoSuchElementException();
}
- Map.Entry<String, String> redisKeyValue = null;
- if (pendingIterator != null) {
- redisKeyValue = pendingIterator.next();
- } else {
- if (cachedResult == null || readPosition >= cachedResult.size()) {
- JedisCommands commands = null;
- try {
- commands = jedisContainer.getInstance();
- ScanResult<Map.Entry<String, String>> scanResult = commands.hscan(namespace, cursor, scanParams);
- cachedResult = scanResult.getResult();
- cursor = scanResult.getStringCursor();
- readPosition = 0;
- } finally {
- jedisContainer.returnInstance(commands);
- }
- }
- redisKeyValue = cachedResult.get(readPosition);
- readPosition += 1;
- }
+ Map.Entry<String, String> redisKeyValue = pendingIterator.next();
K key = decoder.decodeKey(redisKeyValue.getKey());
V value = decoder.decodeValue(redisKeyValue.getValue());
+
+ providedKeys.add(redisKeyValue.getKey());
return new AbstractMap.SimpleEntry(key, value);
}
@@ -107,4 +133,39 @@ public class RedisKeyValueStateIterator<K, V> implements Iterator<Map.Entry<K, V
public void remove() {
throw new UnsupportedOperationException();
}
+
+ private boolean seekToAvailableEntry(PeekingIterator<Map.Entry<String, String>> iterator) {
+ if (iterator != null) {
+ while (iterator.hasNext()) {
+ Map.Entry<String, String> entry = iterator.peek();
+ if (!providedKeys.contains(entry.getKey())) {
+ if (entry.getValue().equals(RedisEncoder.TOMBSTONE)) {
+ providedKeys.add(entry.getKey());
+ } else {
+ return true;
+ }
+ }
+
+ iterator.next();
+ }
+ }
+
+ return false;
+ }
+
+ private void loadChunkFromRedis() {
+ JedisCommands commands = null;
+ try {
+ commands = jedisContainer.getInstance();
+ ScanResult<Map.Entry<String, String>> scanResult = commands.hscan(namespace, cursor, scanParams);
+ List<Map.Entry<String, String>> result = scanResult.getResult();
+ if (result != null) {
+ cachedResultIterator = Iterators.peekingIterator(result.iterator());
+ }
+ cursor = scanResult.getStringCursor();
+ } finally {
+ jedisContainer.returnInstance(commands);
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/storm/blob/819f9177/external/storm-redis/src/test/java/org/apache/storm/redis/state/RedisKeyValueStateIteratorTest.java
----------------------------------------------------------------------
diff --git a/external/storm-redis/src/test/java/org/apache/storm/redis/state/RedisKeyValueStateIteratorTest.java b/external/storm-redis/src/test/java/org/apache/storm/redis/state/RedisKeyValueStateIteratorTest.java
new file mode 100644
index 0000000..1e54ca2
--- /dev/null
+++ b/external/storm-redis/src/test/java/org/apache/storm/redis/state/RedisKeyValueStateIteratorTest.java
@@ -0,0 +1,264 @@
+/**
+ * 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.storm.redis.state;
+
+import org.apache.storm.redis.common.container.JedisCommandsInstanceContainer;
+import org.apache.storm.redis.utils.RedisEncoder;
+import org.apache.storm.state.DefaultStateSerializer;
+import org.apache.storm.state.Serializer;
+import org.junit.Before;
+import org.junit.Test;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.ScanParams;
+import redis.clients.jedis.ScanResult;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.TreeMap;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Test for RedisKeyValueStateIterator.
+ */
+public class RedisKeyValueStateIteratorTest {
+
+ private String namespace;
+ private JedisCommandsInstanceContainer mockContainer;
+ private Jedis mockJedis;
+ private int chunkSize = 1000;
+ private Serializer<String> keySerializer = new DefaultStateSerializer<>();
+ private Serializer<String> valueSerializer = new DefaultStateSerializer<>();
+ private RedisEncoder<String, String> encoder;
+
+ @Before
+ public void setUp() {
+ namespace = "namespace";
+ mockContainer = mock(JedisCommandsInstanceContainer.class);
+ mockJedis = mock(Jedis.class);
+ when(mockContainer.getInstance()).thenReturn(mockJedis);
+
+ encoder = new RedisEncoder<>(keySerializer, valueSerializer);
+ }
+
+ @Test
+ public void testGetEntriesFromPendingPrepare() {
+ Map<String, String> pendingPrepare = new TreeMap<>();
+ putEncodedKeyValueToMap(pendingPrepare, "key0", "value0");
+ putTombstoneToMap(pendingPrepare, "key1");
+ putEncodedKeyValueToMap(pendingPrepare, "key2", "value2");
+
+ Map<String, String> pendingCommit = new TreeMap<>();
+
+ ScanResult<Map.Entry<String, String>> scanResult = new ScanResult<Map.Entry<String, String>>(
+ ScanParams.SCAN_POINTER_START, new ArrayList<Map.Entry<String, String>>());
+ when(mockJedis.hscan(eq(namespace), anyString(), any(ScanParams.class))).thenReturn(scanResult);
+
+ RedisKeyValueStateIterator<String, String> kvIterator =
+ new RedisKeyValueStateIterator<>(namespace, mockContainer, pendingPrepare.entrySet().iterator(),
+ pendingCommit.entrySet().iterator(), chunkSize, keySerializer, valueSerializer);
+
+ assertNextEntry(kvIterator, "key0", "value0");
+
+ // key1 shouldn't in iterator
+
+ assertNextEntry(kvIterator, "key2", "value2");
+
+ assertFalse(kvIterator.hasNext());
+ }
+
+ @Test
+ public void testGetEntriesFromPendingCommit() {
+ Map<String, String> pendingPrepare = new TreeMap<>();
+
+ Map<String, String> pendingCommit = new TreeMap<>();
+ putEncodedKeyValueToMap(pendingCommit, "key0", "value0");
+ putTombstoneToMap(pendingCommit, "key1");
+ putEncodedKeyValueToMap(pendingCommit, "key2", "value2");
+
+ ScanResult<Map.Entry<String, String>> scanResult = new ScanResult<Map.Entry<String, String>>(
+ ScanParams.SCAN_POINTER_START, new ArrayList<Map.Entry<String, String>>());
+ when(mockJedis.hscan(eq(namespace), anyString(), any(ScanParams.class))).thenReturn(scanResult);
+
+ RedisKeyValueStateIterator<String, String> kvIterator =
+ new RedisKeyValueStateIterator<>(namespace, mockContainer, pendingPrepare.entrySet().iterator(),
+ pendingCommit.entrySet().iterator(), chunkSize, keySerializer, valueSerializer);
+
+ assertNextEntry(kvIterator, "key0", "value0");
+
+ // key1 shouldn't in iterator
+
+ assertNextEntry(kvIterator, "key2", "value2");
+
+ assertFalse(kvIterator.hasNext());
+ }
+
+ @Test
+ public void testGetEntriesFromFirstPartOfChunkInRedis() {
+ // pendingPrepare has no entries
+ Map<String, String> pendingPrepare = new TreeMap<>();
+
+ // pendingCommit has no entries
+ Map<String, String> pendingCommit = new TreeMap<>();
+
+ // Redis has a chunk but no more
+ Map<String, String> chunkMap = new TreeMap<>();
+ putEncodedKeyValueToMap(chunkMap, "key0", "value0");
+ putEncodedKeyValueToMap(chunkMap, "key2", "value2");
+
+ ScanResult<Map.Entry<String, String>> scanResultFirst = new ScanResult<>(
+ "12345", new ArrayList<>(chunkMap.entrySet()));
+ ScanResult<Map.Entry<String, String>> scanResultSecond = new ScanResult<>(
+ ScanParams.SCAN_POINTER_START, new ArrayList<Map.Entry<String, String>>());
+ when(mockJedis.hscan(eq(namespace), anyString(), any(ScanParams.class)))
+ .thenReturn(scanResultFirst, scanResultSecond);
+
+ RedisKeyValueStateIterator<String, String> kvIterator =
+ new RedisKeyValueStateIterator<>(namespace, mockContainer, pendingPrepare.entrySet().iterator(),
+ pendingCommit.entrySet().iterator(), chunkSize, keySerializer, valueSerializer);
+
+ assertNextEntry(kvIterator, "key0", "value0");
+
+ // key1 shouldn't in iterator
+
+ assertNextEntry(kvIterator, "key2", "value2");
+
+ assertFalse(kvIterator.hasNext());
+ }
+
+ @Test
+ public void testGetEntriesFromThirdPartOfChunkInRedis() {
+ // pendingPrepare has no entries
+ Map<String, String> pendingPrepare = new TreeMap<>();
+
+ // pendingCommit has no entries
+ Map<String, String> pendingCommit = new TreeMap<>();
+
+ // Redis has three chunks which last chunk only has entries
+ Map<String, String> chunkMap = new TreeMap<>();
+ putEncodedKeyValueToMap(chunkMap, "key0", "value0");
+ putEncodedKeyValueToMap(chunkMap, "key2", "value2");
+
+ ScanResult<Map.Entry<String, String>> scanResultFirst = new ScanResult<>(
+ "12345", new ArrayList<Map.Entry<String, String>>());
+ ScanResult<Map.Entry<String, String>> scanResultSecond = new ScanResult<>(
+ "23456", new ArrayList<Map.Entry<String, String>>());
+ ScanResult<Map.Entry<String, String>> scanResultThird = new ScanResult<>(
+ ScanParams.SCAN_POINTER_START, new ArrayList<>(chunkMap.entrySet()));
+ when(mockJedis.hscan(eq(namespace), anyString(), any(ScanParams.class)))
+ .thenReturn(scanResultFirst, scanResultSecond, scanResultThird);
+
+ RedisKeyValueStateIterator<String, String> kvIterator =
+ new RedisKeyValueStateIterator<>(namespace, mockContainer, pendingPrepare.entrySet().iterator(),
+ pendingCommit.entrySet().iterator(), chunkSize, keySerializer, valueSerializer);
+
+ assertNextEntry(kvIterator, "key0", "value0");
+
+ // key1 shouldn't in iterator
+
+ assertNextEntry(kvIterator, "key2", "value2");
+
+ assertFalse(kvIterator.hasNext());
+ }
+
+ @Test
+ public void testGetEntriesRemovingDuplicationKeys() {
+ Map<String, String> pendingPrepare = new TreeMap<>();
+ putEncodedKeyValueToMap(pendingPrepare, "key0", "value0");
+ putTombstoneToMap(pendingPrepare, "key1");
+
+ Map<String, String> pendingCommit = new TreeMap<>();
+ putEncodedKeyValueToMap(pendingCommit, "key1", "value1");
+ putEncodedKeyValueToMap(pendingCommit, "key2", "value2");
+
+ Map<String, String> chunkMap = new TreeMap<>();
+ putEncodedKeyValueToMap(chunkMap, "key2", "value2");
+ putEncodedKeyValueToMap(chunkMap, "key3", "value3");
+
+ Map<String, String> chunkMap2 = new TreeMap<>();
+ putEncodedKeyValueToMap(chunkMap2, "key3", "value3");
+ putEncodedKeyValueToMap(chunkMap2, "key4", "value4");
+
+ ScanResult<Map.Entry<String, String>> scanResultFirst = new ScanResult<>(
+ "12345", new ArrayList<>(chunkMap.entrySet()));
+ ScanResult<Map.Entry<String, String>> scanResultSecond = new ScanResult<>(
+ "23456", new ArrayList<>(chunkMap2.entrySet()));
+ ScanResult<Map.Entry<String, String>> scanResultThird = new ScanResult<>(
+ ScanParams.SCAN_POINTER_START, new ArrayList<Map.Entry<String, String>>());
+ when(mockJedis.hscan(eq(namespace), anyString(), any(ScanParams.class)))
+ .thenReturn(scanResultFirst, scanResultSecond, scanResultThird);
+
+ RedisKeyValueStateIterator<String, String> kvIterator =
+ new RedisKeyValueStateIterator<>(namespace, mockContainer, pendingPrepare.entrySet().iterator(),
+ pendingCommit.entrySet().iterator(), chunkSize, keySerializer, valueSerializer);
+
+ // keys shouldn't appear twice
+
+ assertNextEntry(kvIterator, "key0", "value0");
+
+ // key1 shouldn't be in iterator since it's marked as deleted
+
+ assertNextEntry(kvIterator, "key2", "value2");
+ assertNextEntry(kvIterator, "key3", "value3");
+ assertNextEntry(kvIterator, "key4", "value4");
+
+ assertFalse(kvIterator.hasNext());
+ }
+
+ @Test
+ public void testGetEntryNotAvailable() {
+ Map<String, String> pendingPrepare = new TreeMap<>();
+
+ Map<String, String> pendingCommit = new TreeMap<>();
+
+ ScanResult<Map.Entry<String, String>> scanResult = new ScanResult<>(
+ ScanParams.SCAN_POINTER_START, new ArrayList<Map.Entry<String, String>>());
+ when(mockJedis.hscan(eq(namespace), anyString(), any(ScanParams.class)))
+ .thenReturn(scanResult);
+
+ RedisKeyValueStateIterator<String, String> kvIterator =
+ new RedisKeyValueStateIterator<>(namespace, mockContainer, pendingPrepare.entrySet().iterator(),
+ pendingCommit.entrySet().iterator(), chunkSize, keySerializer, valueSerializer);
+
+ assertFalse(kvIterator.hasNext());
+ }
+
+ private void assertNextEntry(RedisKeyValueStateIterator<String, String> kvIterator, String expectedKey,
+ String expectedValue) {
+ assertTrue(kvIterator.hasNext());
+ Map.Entry<String, String> entry = kvIterator.next();
+ assertEquals(expectedKey, entry.getKey());
+ assertEquals(expectedValue, entry.getValue());
+ }
+
+ private void putEncodedKeyValueToMap(Map<String, String> map, String key, String value) {
+ map.put(encoder.encodeKey(key), encoder.encodeValue(value));
+ }
+
+ private void putTombstoneToMap(Map<String, String> map, String key) {
+ map.put(encoder.encodeKey(key), RedisEncoder.TOMBSTONE);
+ }
+}
\ No newline at end of file
[20/40] storm git commit: Merge branch 'STORM-2486' of
https://github.com/erikdw/storm into STORM-2486
Posted by ka...@apache.org.
Merge branch 'STORM-2486' of https://github.com/erikdw/storm into STORM-2486
STORM-2486: Prevent cd from printing target directory to avoid breaking classpath
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/711115fd
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/711115fd
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/711115fd
Branch: refs/heads/1.1.x-branch
Commit: 711115fd0d8c4820b9739b926b20b31548cd34d4
Parents: 488b015
Author: Robert Evans <ev...@yahoo-inc.com>
Authored: Thu Apr 27 21:17:44 2017 -0500
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:40:14 2017 +0900
----------------------------------------------------------------------
bin/storm | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/711115fd/bin/storm
----------------------------------------------------------------------
diff --git a/bin/storm b/bin/storm
index 0963065..243b017 100755
--- a/bin/storm
+++ b/bin/storm
@@ -17,6 +17,9 @@
# limitations under the License.
#
+# STORM-2486: Prevent `cd` from printing the target directory.
+unset CDPATH
+
# Resolve links - $0 may be a softlink
PRG="${0}"
[38/40] storm git commit: STORM-2568: Fix getTopicsString -
String.valueOf returns square bracket,
because topics is Collection - removed square bracket to use
storm-kafka-monitor
Posted by ka...@apache.org.
STORM-2568: Fix getTopicsString
- String.valueOf returns square bracket, because topics is Collection
- removed square bracket to use storm-kafka-monitor
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/097a14b0
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/097a14b0
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/097a14b0
Branch: refs/heads/1.1.x-branch
Commit: 097a14b09ba37ae9a9a9c91d31f482231c60468b
Parents: 588287a
Author: haewanj <ha...@gmail.com>
Authored: Sat Jun 24 15:07:34 2017 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 17:01:05 2017 +0900
----------------------------------------------------------------------
external/storm-kafka-client/pom.xml | 4 ++
.../storm/kafka/spout/NamedSubscription.java | 3 +-
.../kafka/spout/NamedSubscriptionTest.java | 54 ++++++++++++++++++++
3 files changed, 60 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/097a14b0/external/storm-kafka-client/pom.xml
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/pom.xml b/external/storm-kafka-client/pom.xml
index c95c6e2..b6dafab 100644
--- a/external/storm-kafka-client/pom.xml
+++ b/external/storm-kafka-client/pom.xml
@@ -40,6 +40,10 @@
</developers>
<dependencies>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
<!--parent module dependency-->
<dependency>
<groupId>org.apache.storm</groupId>
http://git-wip-us.apache.org/repos/asf/storm/blob/097a14b0/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/NamedSubscription.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/NamedSubscription.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/NamedSubscription.java
index 6c5dcfb..3409184 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/NamedSubscription.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/NamedSubscription.java
@@ -22,6 +22,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import org.apache.commons.lang.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRebalanceListener;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.storm.task.TopologyContext;
@@ -56,6 +57,6 @@ public class NamedSubscription extends Subscription {
@Override
public String getTopicsString() {
- return String.valueOf(topics);
+ return StringUtils.join(topics, ",");
}
}
http://git-wip-us.apache.org/repos/asf/storm/blob/097a14b0/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/NamedSubscriptionTest.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/NamedSubscriptionTest.java b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/NamedSubscriptionTest.java
new file mode 100644
index 0000000..56bfddf
--- /dev/null
+++ b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/NamedSubscriptionTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.storm.kafka.spout;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import static org.junit.Assert.*;
+
+public class NamedSubscriptionTest {
+
+ private NamedSubscription namedSubscription;
+
+ @Test
+ public void testGetTopicsStringWithOneTopic() throws Exception {
+ Collection<String> topics = new ArrayList<>();
+ topics.add("test-topic1");
+
+ namedSubscription = new NamedSubscription(topics);
+
+ Assert.assertEquals(namedSubscription.getTopicsString(), "test-topic1");
+ }
+
+ @Test
+ public void testGetTopicsStringWithManyTopics() throws Exception {
+ Collection<String> topics = new ArrayList<>();
+ topics.add("test-topic1");
+ topics.add("test-topic2");
+ topics.add("test-topic3");
+
+ namedSubscription = new NamedSubscription(topics);
+
+ Assert.assertEquals(namedSubscription.getTopicsString(), "test-topic1,test-topic2,test-topic3");
+ }
+
+}
\ No newline at end of file
[08/40] storm git commit: fix md formatting for windows
storm.local.dir example (jekyll needs a newline before the code quotes)
Posted by ka...@apache.org.
fix md formatting for windows storm.local.dir example (jekyll needs a newline before the code quotes)
Signed-off-by: alexlehm <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/74eaf38c
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/74eaf38c
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/74eaf38c
Branch: refs/heads/1.1.x-branch
Commit: 74eaf38c23ed2d6d9de13f68a85362ae16606e0d
Parents: bdeadfb
Author: alexlehm <al...@gmail.com>
Authored: Sun Apr 2 12:49:01 2017 +0200
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:28:37 2017 +0900
----------------------------------------------------------------------
docs/Setting-up-a-Storm-cluster.md | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/74eaf38c/docs/Setting-up-a-Storm-cluster.md
----------------------------------------------------------------------
diff --git a/docs/Setting-up-a-Storm-cluster.md b/docs/Setting-up-a-Storm-cluster.md
index 45005e2..a251d1a 100644
--- a/docs/Setting-up-a-Storm-cluster.md
+++ b/docs/Setting-up-a-Storm-cluster.md
@@ -17,11 +17,11 @@ Here's a summary of the steps for setting up a Storm cluster:
### Set up a Zookeeper cluster
-Storm uses Zookeeper for coordinating the cluster. Zookeeper **is not** used for message passing, so the load Storm places on Zookeeper is quite low. Single node Zookeeper clusters should be sufficient for most cases, but if you want failover or are deploying large Storm clusters you may want larger Zookeeper clusters. Instructions for deploying Zookeeper are [here](http://zookeeper.apache.org/doc/r3.3.3/zookeeperAdmin.html).
+Storm uses Zookeeper for coordinating the cluster. Zookeeper **is not** used for message passing, so the load Storm places on Zookeeper is quite low. Single node Zookeeper clusters should be sufficient for most cases, but if you want failover or are deploying large Storm clusters you may want larger Zookeeper clusters. Instructions for deploying Zookeeper are [here](http://zookeeper.apache.org/doc/r3.3.3/zookeeperAdmin.html).
A few notes about Zookeeper deployment:
-1. It's critical that you run Zookeeper under supervision, since Zookeeper is fail-fast and will exit the process if it encounters any error case. See [here](http://zookeeper.apache.org/doc/r3.3.3/zookeeperAdmin.html#sc_supervision) for more details.
+1. It's critical that you run Zookeeper under supervision, since Zookeeper is fail-fast and will exit the process if it encounters any error case. See [here](http://zookeeper.apache.org/doc/r3.3.3/zookeeperAdmin.html#sc_supervision) for more details.
2. It's critical that you set up a cron to compact Zookeeper's data and transaction logs. The Zookeeper daemon does not do this on its own, and if you don't set up a cron, Zookeeper will quickly run out of disk space. See [here](http://zookeeper.apache.org/doc/r3.3.3/zookeeperAdmin.html#sc_maintenance) for more details.
### Install dependencies on Nimbus and worker machines
@@ -58,11 +58,12 @@ If the port that your Zookeeper cluster uses is different than the default, you
```yaml
storm.local.dir: "/mnt/storm"
```
-If you run storm on windows,it could be:
+If you run storm on windows, it could be:
+
```yaml
storm.local.dir: "C:\\storm-local"
```
-If you use a relative path,it will be relative to where you installed storm(STORM_HOME).
+If you use a relative path, it will be relative to where you installed storm(STORM_HOME).
You can leave it empty with default value `$STORM_HOME/storm-local`
3) **nimbus.seeds**: The worker nodes need to know which machines are the candidate of master in order to download topology jars and confs. For example:
@@ -84,7 +85,7 @@ supervisor.slots.ports:
### Monitoring Health of Supervisors
-Storm provides a mechanism by which administrators can configure the supervisor to run administrator supplied scripts periodically to determine if a node is healthy or not. Administrators can have the supervisor determine if the node is in a healthy state by performing any checks of their choice in scripts located in storm.health.check.dir. If a script detects the node to be in an unhealthy state, it must print a line to standard output beginning with the string ERROR. The supervisor will periodically run the scripts in the health check dir and check the output. If the script’s output contains the string ERROR, as described above, the supervisor will shut down any workers and exit.
+Storm provides a mechanism by which administrators can configure the supervisor to run administrator supplied scripts periodically to determine if a node is healthy or not. Administrators can have the supervisor determine if the node is in a healthy state by performing any checks of their choice in scripts located in storm.health.check.dir. If a script detects the node to be in an unhealthy state, it must print a line to standard output beginning with the string ERROR. The supervisor will periodically run the scripts in the health check dir and check the output. If the script’s output contains the string ERROR, as described above, the supervisor will shut down any workers and exit.
If the supervisor is running with supervision "/bin/storm node-health-check" can be called to determine if the supervisor should be launched or if the node is unhealthy.
@@ -112,6 +113,6 @@ The last step is to launch all the Storm daemons. It is critical that you run ea
1. **Nimbus**: Run the command "bin/storm nimbus" under supervision on the master machine.
2. **Supervisor**: Run the command "bin/storm supervisor" under supervision on each worker machine. The supervisor daemon is responsible for starting and stopping worker processes on that machine.
-3. **UI**: Run the Storm UI (a site you can access from the browser that gives diagnostics on the cluster and topologies) by running the command "bin/storm ui" under supervision. The UI can be accessed by navigating your web browser to http://{ui host}:8080.
+3. **UI**: Run the Storm UI (a site you can access from the browser that gives diagnostics on the cluster and topologies) by running the command "bin/storm ui" under supervision. The UI can be accessed by navigating your web browser to http://{ui host}:8080.
As you can see, running the daemons is very straightforward. The daemons will log to the logs/ directory in wherever you extracted the Storm release.
[04/40] storm git commit: [STORM-2440] Kill process if executor
catches `java.net.SocketTimeoutException`
Posted by ka...@apache.org.
[STORM-2440] Kill process if executor catches `java.net.SocketTimeoutException`
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/3a59ee94
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/3a59ee94
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/3a59ee94
Branch: refs/heads/1.1.x-branch
Commit: 3a59ee941e7e93316444feba79358463e16bacd8
Parents: 0f5c185
Author: Nico Meyer <ni...@adition.com>
Authored: Fri Mar 31 16:02:05 2017 +0200
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:23:37 2017 +0900
----------------------------------------------------------------------
storm-core/src/clj/org/apache/storm/daemon/executor.clj | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/3a59ee94/storm-core/src/clj/org/apache/storm/daemon/executor.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/org/apache/storm/daemon/executor.clj b/storm-core/src/clj/org/apache/storm/daemon/executor.clj
index 8c7d026..8126a80 100644
--- a/storm-core/src/clj/org/apache/storm/daemon/executor.clj
+++ b/storm-core/src/clj/org/apache/storm/daemon/executor.clj
@@ -268,8 +268,10 @@
(catch Exception e
(log-message "Error while reporting error to cluster, proceeding with shutdown")))
(if (or
- (exception-cause? InterruptedException error)
- (exception-cause? java.io.InterruptedIOException error))
+ (exception-cause? InterruptedException error)
+ (and
+ (exception-cause? java.io.InterruptedIOException error)
+ (not (exception-cause? java.net.SocketTimeoutException error))))
(log-message "Got interrupted excpetion shutting thread down...")
((:suicide-fn <>))))
:sampler (mk-stats-sampler storm-conf)
[29/40] storm git commit: STORM-2528: Bump log4j version to 2.8.2
Posted by ka...@apache.org.
STORM-2528: Bump log4j version to 2.8.2
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/a8fab3c9
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/a8fab3c9
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/a8fab3c9
Branch: refs/heads/1.1.x-branch
Commit: a8fab3c998f850602daa084f99d565d10ee94402
Parents: 4a55a7d
Author: Balint Molnar <ba...@gmail.com>
Authored: Wed May 24 13:32:06 2017 +0200
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:53:35 2017 +0900
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/a8fab3c9/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index bf54381..f6d4fe0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -246,7 +246,7 @@
<guava.version>16.0.1</guava.version>
<netty.version>3.9.0.Final</netty.version>
<log4j-over-slf4j.version>1.6.6</log4j-over-slf4j.version>
- <log4j.version>2.8</log4j.version>
+ <log4j.version>2.8.2</log4j.version>
<slf4j.version>1.7.21</slf4j.version>
<metrics.version>3.1.0</metrics.version>
<clojure.tools.nrepl.version>0.2.3</clojure.tools.nrepl.version>
[06/40] storm git commit: STORM-2451: windows storm.cmd does not set
log4j2 config file correctly by default
Posted by ka...@apache.org.
STORM-2451: windows storm.cmd does not set log4j2 config file correctly by default
the dir from the default config is log4j2 and that should be relative to STORM_HOME, however this is check was missing
Signed-off-by: alexlehm <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/2cf1a3cb
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/2cf1a3cb
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/2cf1a3cb
Branch: refs/heads/1.1.x-branch
Commit: 2cf1a3cba05a617de8454f41e343957d6be90a64
Parents: bb126ae
Author: alexlehm <al...@gmail.com>
Authored: Sun Apr 2 15:04:10 2017 +0200
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:25:11 2017 +0900
----------------------------------------------------------------------
bin/storm-config.cmd | 10 ++++++++++
1 file changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/2cf1a3cb/bin/storm-config.cmd
----------------------------------------------------------------------
diff --git a/bin/storm-config.cmd b/bin/storm-config.cmd
index 0a9ae5e..f5e677f 100644
--- a/bin/storm-config.cmd
+++ b/bin/storm-config.cmd
@@ -102,6 +102,16 @@ FOR /F "delims=" %%i in (%CMD_TEMP_FILE%) do (
)
@rem
+@rem if we have a dir with relative path, make it absolute
+@rem
+
+if not %STORM_LOG4J2_CONFIGURATION_DIR% == nil (
+ if exist %STORM_HOME%\%STORM_LOG4J2_CONFIGURATION_DIR% (
+ set STORM_LOG4J2_CONFIGURATION_DIR=%STORM_HOME%\%STORM_LOG4J2_CONFIGURATION_DIR%
+ )
+)
+
+@rem
@rem if STORM_LOG4J2_CONFIGURATION_DIR was defined, also set STORM_LOG4J2_CONFIGURATION_FILE
@rem
[37/40] storm git commit: [STORM-2563] Remove the workaround to
handle missing UGI.loginUserFromSubject
Posted by ka...@apache.org.
[STORM-2563] Remove the workaround to handle missing UGI.loginUserFromSubject
https://github.com/apache/storm/blob/master/storm-client/src/jvm/org/apache/storm/security/auth/kerberos/AutoTGT.java#L225
The "userCons.setAccessible(true)" invokes constructor of a package private class bypassing the Java access control checks
and raising red flags in our internal security scans.
The "loginUserFromSubject(Subject subject)" has been added to UGI (https://issues.apache.org/jira/browse/HADOOP-10164)
and available since Hadoop version 2.3 released over three years ago (http://hadoop.apache.org/releases.html).
I think the workaround is no longer required since the case will not happen when using hadoop-common versions >= 2.3
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/588287a7
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/588287a7
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/588287a7
Branch: refs/heads/1.1.x-branch
Commit: 588287a7a7243b44cc1141682415fec3e1237b1c
Parents: 4e258ca
Author: Arun Mahadevan <ar...@apache.org>
Authored: Wed Jun 21 10:11:36 2017 +0530
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 17:00:27 2017 +0900
----------------------------------------------------------------------
.../storm/security/auth/kerberos/AutoTGT.java | 40 +-------------------
1 file changed, 2 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/588287a7/storm-core/src/jvm/org/apache/storm/security/auth/kerberos/AutoTGT.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/security/auth/kerberos/AutoTGT.java b/storm-core/src/jvm/org/apache/storm/security/auth/kerberos/AutoTGT.java
index c3f8560..d02c4e3 100644
--- a/storm-core/src/jvm/org/apache/storm/security/auth/kerberos/AutoTGT.java
+++ b/storm-core/src/jvm/org/apache/storm/security/auth/kerberos/AutoTGT.java
@@ -188,44 +188,8 @@ public class AutoTGT implements IAutoCredentials, ICredentialsRenewer {
"in your jar");
return;
}
-
- try {
- Method login = ugi.getMethod("loginUserFromSubject", Subject.class);
- login.invoke(null, subject);
- } catch (NoSuchMethodException me) {
- //The version of Hadoop does not have the needed client changes.
- // So don't look now, but do something really ugly to work around it.
- // This is because we are reaching into the hidden bits of Hadoop security, and it works for now, but may stop at any point in time.
-
- //We are just trying to do the following
- // Configuration conf = new Configuration();
- // HadoopKerberosName.setConfiguration(conf);
- // subject.getPrincipals().add(new User(tgt.getClient().toString(), AuthenticationMethod.KERBEROS, null));
- String name = getTGT(subject).getClient().toString();
-
- LOG.warn("The Hadoop client does not have loginUserFromSubject, Trying to hack around it. This may not work...");
- Class<?> confClass = Class.forName("org.apache.hadoop.conf.Configuration");
- Constructor confCons = confClass.getConstructor();
- Object conf = confCons.newInstance();
- Class<?> hknClass = Class.forName("org.apache.hadoop.security.HadoopKerberosName");
- Method hknSetConf = hknClass.getMethod("setConfiguration",confClass);
- hknSetConf.invoke(null, conf);
-
- Class<?> authMethodClass = Class.forName("org.apache.hadoop.security.UserGroupInformation$AuthenticationMethod");
- Object kerbAuthMethod = null;
- for (Object authMethod : authMethodClass.getEnumConstants()) {
- if ("KERBEROS".equals(authMethod.toString())) {
- kerbAuthMethod = authMethod;
- break;
- }
- }
-
- Class<?> userClass = Class.forName("org.apache.hadoop.security.User");
- Constructor userCons = userClass.getConstructor(String.class, authMethodClass, LoginContext.class);
- userCons.setAccessible(true);
- Object user = userCons.newInstance(name, kerbAuthMethod, null);
- subject.getPrincipals().add((Principal)user);
- }
+ Method login = ugi.getMethod("loginUserFromSubject", Subject.class);
+ login.invoke(null, subject);
} catch (Exception e) {
LOG.warn("Something went wrong while trying to initialize Hadoop through reflection. This version of hadoop may not be compatible.", e);
}
[28/40] storm git commit: STORM-2527 Initialize
java.sql.DriverManager earlier to avoid deadlock
Posted by ka...@apache.org.
STORM-2527 Initialize java.sql.DriverManager earlier to avoid deadlock
* also fixed some checkstyle violations
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/4a55a7df
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/4a55a7df
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/4a55a7df
Branch: refs/heads/1.1.x-branch
Commit: 4a55a7dfe8814a00606170c12ef62a60bd9d74ad
Parents: db7bcc3
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Tue May 23 19:20:15 2017 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:53:03 2017 +0900
----------------------------------------------------------------------
.../storm/jdbc/bolt/AbstractJdbcBolt.java | 68 +++++++++++++++-----
1 file changed, 52 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/4a55a7df/external/storm-jdbc/src/main/java/org/apache/storm/jdbc/bolt/AbstractJdbcBolt.java
----------------------------------------------------------------------
diff --git a/external/storm-jdbc/src/main/java/org/apache/storm/jdbc/bolt/AbstractJdbcBolt.java b/external/storm-jdbc/src/main/java/org/apache/storm/jdbc/bolt/AbstractJdbcBolt.java
index 9cfbb4e..6258a97 100644
--- a/external/storm-jdbc/src/main/java/org/apache/storm/jdbc/bolt/AbstractJdbcBolt.java
+++ b/external/storm-jdbc/src/main/java/org/apache/storm/jdbc/bolt/AbstractJdbcBolt.java
@@ -15,25 +15,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.storm.jdbc.bolt;
-import org.apache.storm.Config;
-import org.apache.storm.task.OutputCollector;
-import org.apache.storm.task.TopologyContext;
-import org.apache.storm.topology.base.BaseRichBolt;
+import java.sql.DriverManager;
+import java.util.Map;
import org.apache.commons.lang.Validate;
+import org.apache.storm.Config;
import org.apache.storm.jdbc.common.ConnectionProvider;
import org.apache.storm.jdbc.common.JdbcClient;
+import org.apache.storm.task.OutputCollector;
+import org.apache.storm.task.TopologyContext;
import org.apache.storm.topology.base.BaseTickTupleAwareRichBolt;
-import org.apache.storm.tuple.Tuple;
-import org.apache.storm.utils.TupleUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Map;
-
public abstract class AbstractJdbcBolt extends BaseTickTupleAwareRichBolt {
- private static final Logger LOG = LoggerFactory.getLogger(AbstractJdbcBolt.class);
+ private static final Logger LOG = LoggerFactory.getLogger(
+ AbstractJdbcBolt.class);
protected OutputCollector collector;
@@ -42,24 +41,61 @@ public abstract class AbstractJdbcBolt extends BaseTickTupleAwareRichBolt {
protected Integer queryTimeoutSecs;
protected ConnectionProvider connectionProvider;
+ static {
+ /*
+ * Load DriverManager first to avoid any race condition between
+ * DriverManager static initialization block and specific driver class's
+ * static initialization block. e.g. PhoenixDriver
+ *
+ * We should take this workaround since prepare() method is synchronized
+ * but an worker can initialize multiple AbstractJdbcBolt instances and
+ * they would make race condition.
+ *
+ * We just need to ensure that DriverManager class is always initialized
+ * earlier than provider so below line should be called first
+ * than initializing provider.
+ */
+ DriverManager.getDrivers();
+ }
+
+ /**
+ * Subclasses should call this to ensure output collector and connection
+ * provider are set up, and finally jdbcClient is initialized properly.
+ * <p/>
+ * {@inheritDoc}
+ */
@Override
- public void prepare(Map map, TopologyContext topologyContext, OutputCollector collector) {
- this.collector = collector;
+ public void prepare(final Map map, final TopologyContext topologyContext,
+ final OutputCollector outputCollector) {
+ this.collector = outputCollector;
connectionProvider.prepare();
- if(queryTimeoutSecs == null) {
- queryTimeoutSecs = Integer.parseInt(map.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS).toString());
+ if (queryTimeoutSecs == null) {
+ String msgTimeout = map.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS)
+ .toString();
+ queryTimeoutSecs = Integer.parseInt(msgTimeout);
}
this.jdbcClient = new JdbcClient(connectionProvider, queryTimeoutSecs);
}
- public AbstractJdbcBolt(ConnectionProvider connectionProvider) {
- Validate.notNull(connectionProvider);
- this.connectionProvider = connectionProvider;
+ /**
+ * Constructor.
+ * <p/>
+ * @param connectionProviderParam database connection provider
+ */
+ public AbstractJdbcBolt(final ConnectionProvider connectionProviderParam) {
+ Validate.notNull(connectionProviderParam);
+ this.connectionProvider = connectionProviderParam;
}
+ /**
+ * Cleanup.
+ * <p/>
+ * Subclasses should call this to ensure connection provider can be
+ * also cleaned up.
+ */
@Override
public void cleanup() {
connectionProvider.cleanup();
[32/40] storm git commit: [STORM-2466] The example of jaas.conf in
jaas_kerberos.conf should give more details
Posted by ka...@apache.org.
[STORM-2466] The example of jaas.conf in jaas_kerberos.conf should give more details
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/58323243
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/58323243
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/58323243
Branch: refs/heads/1.1.x-branch
Commit: 58323243d75b4b5f6f5afb14d2d906c78aee8cbd
Parents: ae1b384
Author: liuzhaokun <li...@zte.com.cn>
Authored: Fri May 12 08:56:32 2017 +0800
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:56:10 2017 +0900
----------------------------------------------------------------------
conf/jaas_kerberos.conf | 32 ------------------------------
conf/storm_jaas.conf | 45 +++++++++++++++++++++++++++++++++++++++++++
conf/zookeeper_jaas.conf | 35 +++++++++++++++++++++++++++++++++
3 files changed, 80 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/58323243/conf/jaas_kerberos.conf
----------------------------------------------------------------------
diff --git a/conf/jaas_kerberos.conf b/conf/jaas_kerberos.conf
deleted file mode 100644
index 87e8d0d..0000000
--- a/conf/jaas_kerberos.conf
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-StormServer {
- com.sun.security.auth.module.Krb5LoginModule required
- useKeyTab=true
- keyTab="/etc/nimbus_server.keytab"
- storeKey=true
- useTicketCache=false
- principal="nimbus_server/carcloth.corp.yahoo.com@STORM.CORP.YAHOO.COM";
-};
-StormClient {
- com.sun.security.auth.module.Krb5LoginModule required
- doNotPrompt=true
- useTicketCache=true
- serviceName="nimbus_server";
-};
-
http://git-wip-us.apache.org/repos/asf/storm/blob/58323243/conf/storm_jaas.conf
----------------------------------------------------------------------
diff --git a/conf/storm_jaas.conf b/conf/storm_jaas.conf
new file mode 100644
index 0000000..765ca15
--- /dev/null
+++ b/conf/storm_jaas.conf
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+StormServer {
+ com.sun.security.auth.module.Krb5LoginModule required
+ useKeyTab=true
+ keyTab="$keytab"
+ storeKey=true
+ useTicketCache=false
+ principal="$principal";
+};
+StormClient {
+ com.sun.security.auth.module.Krb5LoginModule required
+ useKeyTab=true
+ keyTab="$keytab"
+ storeKey=true
+ useTicketCache=false
+ serviceName="$nimbus_user"
+ principal="$principal";
+};
+Client {
+ com.sun.security.auth.module.Krb5LoginModule required
+ useKeyTab=true
+ keyTab="$keytab"
+ storeKey=true
+ useTicketCache=false
+ serviceName="zookeeper"
+ principal="$principal";
+};
+
+
http://git-wip-us.apache.org/repos/asf/storm/blob/58323243/conf/zookeeper_jaas.conf
----------------------------------------------------------------------
diff --git a/conf/zookeeper_jaas.conf b/conf/zookeeper_jaas.conf
new file mode 100644
index 0000000..c38d55e
--- /dev/null
+++ b/conf/zookeeper_jaas.conf
@@ -0,0 +1,35 @@
+/*
+* 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.
+*/
+Server {
+ com.sun.security.auth.module.Krb5LoginModule required
+ useKeyTab=true
+ keyTab="$keytab"
+ storeKey=true
+ useTicketCache=false
+ principal="$principal";
+};
+Client {
+ com.sun.security.auth.module.Krb5LoginModule required
+ useKeyTab=true
+ keyTab="$keytab"
+ storeKey=true
+ useTicketCache=false
+ serviceName="zookeeper"
+ principal="$principal";
+};
+
[24/40] storm git commit: Merge branch 'STORM-2511' of
https://github.com/satishd/storm into STORM-2511
Posted by ka...@apache.org.
Merge branch 'STORM-2511' of https://github.com/satishd/storm into STORM-2511
STORM-2511: Submitting a topology with name containing unicode getting
failed
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/5a721d7f
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/5a721d7f
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/5a721d7f
Branch: refs/heads/1.1.x-branch
Commit: 5a721d7f0ea9de4f7047472f0dd96d377150959d
Parents: 97605c1
Author: Robert Evans <ev...@yahoo-inc.com>
Authored: Mon May 15 12:27:52 2017 -0500
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:47:29 2017 +0900
----------------------------------------------------------------------
storm-core/src/jvm/org/apache/storm/blobstore/BlobStore.java | 2 +-
.../jvm/org/apache/storm/blobstore/ClientBlobStoreTest.java | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/5a721d7f/storm-core/src/jvm/org/apache/storm/blobstore/BlobStore.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/blobstore/BlobStore.java b/storm-core/src/jvm/org/apache/storm/blobstore/BlobStore.java
index 14879b4..92f32ec 100644
--- a/storm-core/src/jvm/org/apache/storm/blobstore/BlobStore.java
+++ b/storm-core/src/jvm/org/apache/storm/blobstore/BlobStore.java
@@ -61,7 +61,7 @@ import org.apache.storm.generated.SettableBlobMeta;
*/
public abstract class BlobStore implements Shutdownable {
private static final Logger LOG = LoggerFactory.getLogger(BlobStore.class);
- private static final Pattern KEY_PATTERN = Pattern.compile("^[\\w \\t\\.:_-]+$");
+ private static final Pattern KEY_PATTERN = Pattern.compile("^[\\w \\t\\.:_-]+$", Pattern.UNICODE_CHARACTER_CLASS);
protected static final String BASE_BLOBS_DIR_NAME = "blobs";
/**
http://git-wip-us.apache.org/repos/asf/storm/blob/5a721d7f/storm-core/test/jvm/org/apache/storm/blobstore/ClientBlobStoreTest.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/blobstore/ClientBlobStoreTest.java b/storm-core/test/jvm/org/apache/storm/blobstore/ClientBlobStoreTest.java
index 742c917..448a381 100644
--- a/storm-core/test/jvm/org/apache/storm/blobstore/ClientBlobStoreTest.java
+++ b/storm-core/test/jvm/org/apache/storm/blobstore/ClientBlobStoreTest.java
@@ -164,6 +164,12 @@ public class ClientBlobStoreTest {
validatedBlobAcls(testKey);
}
+ @Test
+ public void testBloblStoreKeyWithUnicodesValidation() throws Exception {
+ BlobStore.validateKey("msg:kafka-unicodewriter䶵-11-1483434711-stormconf.ser");
+ BlobStore.validateKey("msg:kafka-ascii-11-148343436363-stormconf.ser");
+ }
+
private void createTestBlob(String testKey, SettableBlobMeta meta) throws AuthorizationException, KeyAlreadyExistsException {
AccessControl submitterAcl = BlobStoreAclHandler.parseAccessControl("u:tester:rwa");
meta.add_to_acl(submitterAcl);
[31/40] storm git commit: STORM-2516: Fix timing issues with
testPrepareLateTupleStreamWithoutBuilder
Posted by ka...@apache.org.
STORM-2516: Fix timing issues with testPrepareLateTupleStreamWithoutBuilder
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/ae1b3845
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/ae1b3845
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/ae1b3845
Branch: refs/heads/1.1.x-branch
Commit: ae1b38457e2f4a0aaad3b29c4b00acbd26da6afd
Parents: ce8081e
Author: Stig Rohde Døssing <st...@gmail.com>
Authored: Tue May 16 21:27:41 2017 +0200
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:55:40 2017 +0900
----------------------------------------------------------------------
.../windowing/WaterMarkEventGenerator.java | 28 +++++++++++++-------
.../topology/WindowedBoltExecutorTest.java | 26 +++++++++---------
2 files changed, 31 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/ae1b3845/storm-core/src/jvm/org/apache/storm/windowing/WaterMarkEventGenerator.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/windowing/WaterMarkEventGenerator.java b/storm-core/src/jvm/org/apache/storm/windowing/WaterMarkEventGenerator.java
index e1df72c..d4f431f 100644
--- a/storm-core/src/jvm/org/apache/storm/windowing/WaterMarkEventGenerator.java
+++ b/storm-core/src/jvm/org/apache/storm/windowing/WaterMarkEventGenerator.java
@@ -15,12 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.storm.windowing;
-import org.apache.storm.generated.GlobalStreamId;
-import org.apache.storm.topology.FailedException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+package org.apache.storm.windowing;
import java.util.Map;
import java.util.Set;
@@ -30,6 +26,11 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.storm.generated.GlobalStreamId;
+import org.apache.storm.topology.FailedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Tracks tuples across input streams and periodically emits watermark events.
@@ -46,15 +47,22 @@ public class WaterMarkEventGenerator<T> implements Runnable {
private final ScheduledExecutorService executorService;
private final int interval;
private ScheduledFuture<?> executorFuture;
- private long lastWaterMarkTs = 0;
+ private volatile long lastWaterMarkTs;
- public WaterMarkEventGenerator(WindowManager<T> windowManager, int interval,
- int eventTsLag, Set<GlobalStreamId> inputStreams) {
+ /**
+ * Creates a new WatermarkEventGenerator.
+ * @param windowManager The window manager this generator will submit watermark events to
+ * @param intervalMs The generator will check if it should generate a watermark event with this interval
+ * @param eventTsLagMs The max allowed lag behind the last watermark event before an event is considered late
+ * @param inputStreams The input streams this generator is expected to handle
+ */
+ public WaterMarkEventGenerator(WindowManager<T> windowManager, int intervalMs,
+ int eventTsLagMs, Set<GlobalStreamId> inputStreams) {
this.windowManager = windowManager;
streamToTs = new ConcurrentHashMap<>();
executorService = Executors.newSingleThreadScheduledExecutor();
- this.interval = interval;
- this.eventTsLag = eventTsLag;
+ this.interval = intervalMs;
+ this.eventTsLag = eventTsLagMs;
this.inputStreams = inputStreams;
}
http://git-wip-us.apache.org/repos/asf/storm/blob/ae1b3845/storm-core/test/jvm/org/apache/storm/topology/WindowedBoltExecutorTest.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/topology/WindowedBoltExecutorTest.java b/storm-core/test/jvm/org/apache/storm/topology/WindowedBoltExecutorTest.java
index a051a6b..76fdf33 100644
--- a/storm-core/test/jvm/org/apache/storm/topology/WindowedBoltExecutorTest.java
+++ b/storm-core/test/jvm/org/apache/storm/topology/WindowedBoltExecutorTest.java
@@ -28,7 +28,6 @@ import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Tuple;
import org.apache.storm.tuple.TupleImpl;
import org.apache.storm.tuple.Values;
-import org.apache.storm.utils.Time;
import org.apache.storm.windowing.TupleWindow;
import org.junit.Before;
import org.junit.Test;
@@ -52,7 +51,7 @@ import static org.junit.Assert.fail;
* Unit tests for {@link WindowedBoltExecutor}
*/
public class WindowedBoltExecutorTest {
-
+
private WindowedBoltExecutor executor;
private TestWindowedBolt testWindowedBolt;
@@ -124,8 +123,8 @@ public class WindowedBoltExecutorTest {
@Test
public void testExecuteWithTs() throws Exception {
- long[] timstamps = {603, 605, 607, 618, 626, 636};
- for (long ts : timstamps) {
+ long[] timestamps = {603, 605, 607, 618, 626, 636};
+ for (long ts : timestamps) {
executor.execute(getTuple("s1", new Fields("ts"), new Values(ts)));
}
//Thread.sleep(120);
@@ -172,7 +171,7 @@ public class WindowedBoltExecutorTest {
@Test
- public void testPrepareLateTUpleStreamWithoutBuilder() throws Exception {
+ public void testPrepareLateTupleStreamWithoutBuilder() throws Exception {
Map<String, Object> conf = new HashMap<>();
conf.put(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 100000);
conf.put(Config.TOPOLOGY_BOLTS_WINDOW_LENGTH_DURATION_MS, 20);
@@ -209,20 +208,21 @@ public class WindowedBoltExecutorTest {
conf.put(Config.TOPOLOGY_BOLTS_SLIDING_INTERVAL_DURATION_MS, 10);
conf.put(Config.TOPOLOGY_BOLTS_LATE_TUPLE_STREAM, "$late");
conf.put(Config.TOPOLOGY_BOLTS_TUPLE_TIMESTAMP_MAX_LAG_MS, 5);
- conf.put(Config.TOPOLOGY_BOLTS_WATERMARK_EVENT_INTERVAL_MS, 10);
+ //Trigger manually to avoid timing issues
+ conf.put(Config.TOPOLOGY_BOLTS_WATERMARK_EVENT_INTERVAL_MS, 1_000_000);
executor.prepare(conf, context, outputCollector);
- long[] timstamps = {603, 605, 607, 618, 626, 636, 600};
- List<Tuple> tuples = new ArrayList<>(timstamps.length);
+ long[] timestamps = {603, 605, 607, 618, 626, 636, 600};
+ List<Tuple> tuples = new ArrayList<>(timestamps.length);
- executor.waterMarkEventGenerator.run();
- for (long ts : timstamps) {
+ for (long ts : timestamps) {
Tuple tuple = getTuple("s1", new Fields("ts"), new Values(ts));
tuples.add(tuple);
executor.execute(tuple);
- Time.sleep(10);
- }
-
+
+ //Update the watermark to this timestamp
+ executor.waterMarkEventGenerator.run();
+ }
System.out.println(testWindowedBolt.tupleWindows);
Tuple tuple = tuples.get(tuples.size() - 1);
Mockito.verify(outputCollector).emit("$late", Arrays.asList(tuple), new Values(tuple));
[09/40] storm git commit: [STORM-2431]the default blobstore.dir is
storm.local.dir/blobs which is different from distcache-blobstore.md
Posted by ka...@apache.org.
[STORM-2431]the default blobstore.dir is storm.local.dir/blobs which is different from distcache-blobstore.md
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/29c349d1
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/29c349d1
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/29c349d1
Branch: refs/heads/1.1.x-branch
Commit: 29c349d1d1f1a66997f19ae7f1f3695568c8cc4d
Parents: 74eaf38
Author: liuzhaokun <li...@zte.com.cn>
Authored: Wed Mar 29 12:04:36 2017 +0800
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:28:57 2017 +0900
----------------------------------------------------------------------
docs/distcache-blobstore.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/29c349d1/docs/distcache-blobstore.md
----------------------------------------------------------------------
diff --git a/docs/distcache-blobstore.md b/docs/distcache-blobstore.md
index 9e6df8a..350b5de 100644
--- a/docs/distcache-blobstore.md
+++ b/docs/distcache-blobstore.md
@@ -115,12 +115,12 @@ the responsibility of mapping the blob to a local name on the supervisor node.
## Additional Blobstore Implementation Details
Blobstore uses a hashing function to create the blobs based on the key. The blobs are generally stored inside the directory specified by
-the blobstore.dir configuration. By default, it is stored under “storm.local.dir/nimbus/blobs” for local file system and a similar path on
+the blobstore.dir configuration. By default, it is stored under “storm.local.dir/blobs” for local file system and a similar path on
hdfs file system.
Once a file is submitted, the blobstore reads the configs and creates a metadata for the blob with all the access control details. The metadata
is generally used for authorization while accessing the blobs. The blob key and version contribute to the hash code and there by the directory
-under “storm.local.dir/nimbus/blobs/data” where the data is placed. The blobs are generally placed in a positive number directory like 193,822 etc.
+under “storm.local.dir/blobs/data” where the data is placed. The blobs are generally placed in a positive number directory like 193,822 etc.
Once the topology is launched and the relevant blobs have been created, the supervisor downloads blobs related to the storm.conf, storm.ser
and storm.code first and all the blobs uploaded by the command line separately using the localizer to uncompress and map them to a local name
[27/40] storm git commit: STORM-2413 Make new Kafka spout respect
tuple retry limits
Posted by ka...@apache.org.
STORM-2413 Make new Kafka spout respect tuple retry limits
* fix failing tests only for 1.x branch
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/db7bcc33
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/db7bcc33
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/db7bcc33
Branch: refs/heads/1.1.x-branch
Commit: db7bcc337a6560c8d4d1b26019285dbca03c4204
Parents: fae07d9
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Sun May 21 20:41:35 2017 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:50:19 2017 +0900
----------------------------------------------------------------------
.../kafka/spout/KafkaSpoutRebalanceTest.java | 14 ++++++--
.../kafka/spout/SingleTopicKafkaSpoutTest.java | 34 +++++++++++++++++---
2 files changed, 42 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/db7bcc33/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutRebalanceTest.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutRebalanceTest.java b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutRebalanceTest.java
index 81e3807..bd6e582 100644
--- a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutRebalanceTest.java
+++ b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/KafkaSpoutRebalanceTest.java
@@ -17,6 +17,7 @@ package org.apache.storm.kafka.spout;
import static org.apache.storm.kafka.spout.builders.SingleTopicKafkaSpoutConfiguration.getKafkaSpoutConfigBuilder;
import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.Matchers.any;
import static org.hamcrest.Matchers.hasKey;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.anyCollection;
@@ -59,15 +60,17 @@ public class KafkaSpoutRebalanceTest {
private ArgumentCaptor<Map<TopicPartition, OffsetAndMetadata>> commitCapture;
private final long offsetCommitPeriodMs = 2_000;
- private final TopologyContext contextMock = mock(TopologyContext.class);
- private final SpoutOutputCollector collectorMock = mock(SpoutOutputCollector.class);
private final Map<String, Object> conf = new HashMap<>();
+ private TopologyContext contextMock;
+ private SpoutOutputCollector collectorMock;
private KafkaConsumer<String, String> consumerMock;
private KafkaConsumerFactory<String, String> consumerFactoryMock;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ contextMock = mock(TopologyContext.class);
+ collectorMock = mock(SpoutOutputCollector.class);
consumerMock = mock(KafkaConsumer.class);
consumerFactoryMock = new KafkaConsumerFactory<String, String>(){
@Override
@@ -165,9 +168,16 @@ public class KafkaSpoutRebalanceTest {
TopicPartition partitionThatWillBeRevoked = new TopicPartition(topic, 1);
TopicPartition assignedPartition = new TopicPartition(topic, 2);
+ when(retryServiceMock.getMessageId(Mockito.any(ConsumerRecord.class)))
+ .thenReturn(new KafkaSpoutMessageId(partitionThatWillBeRevoked, 0))
+ .thenReturn(new KafkaSpoutMessageId(assignedPartition, 0));
+
//Emit a message on each partition and revoke the first partition
List<KafkaSpoutMessageId> emittedMessageIds = emitOneMessagePerPartitionThenRevokeOnePartition(spout, partitionThatWillBeRevoked, assignedPartition);
+ //Check that only two message ids were generated
+ verify(retryServiceMock, times(2)).getMessageId(Mockito.any(ConsumerRecord.class));
+
//Fail both emitted tuples
spout.fail(emittedMessageIds.get(0));
spout.fail(emittedMessageIds.get(1));
http://git-wip-us.apache.org/repos/asf/storm/blob/db7bcc33/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/SingleTopicKafkaSpoutTest.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/SingleTopicKafkaSpoutTest.java b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/SingleTopicKafkaSpoutTest.java
index 884709d..6042c80 100644
--- a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/SingleTopicKafkaSpoutTest.java
+++ b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/SingleTopicKafkaSpoutTest.java
@@ -17,7 +17,6 @@
*/
package org.apache.storm.kafka.spout;
-
import static org.apache.storm.kafka.spout.builders.SingleTopicKafkaSpoutConfiguration.getKafkaSpoutConfigBuilder;
import org.apache.kafka.clients.consumer.OffsetAndMetadata;
@@ -37,11 +36,14 @@ import java.util.concurrent.TimeoutException;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Matchers.anyCollection;
import static org.mockito.Matchers.anyList;
+import static org.mockito.Matchers.anyListOf;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
@@ -61,7 +63,6 @@ import org.junit.Before;
import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
-
public class SingleTopicKafkaSpoutTest {
@Rule
@@ -77,12 +78,15 @@ public class SingleTopicKafkaSpoutTest {
private KafkaConsumer<String, String> consumerSpy;
private KafkaConsumerFactory<String, String> consumerFactory;
private KafkaSpout<String, String> spout;
+ private int maxRetries = 3;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
KafkaSpoutConfig spoutConfig = getKafkaSpoutConfigBuilder(kafkaUnitRule.getKafkaUnit().getKafkaPort())
.setOffsetCommitPeriodMs(commitOffsetPeriodMs)
+ .setRetry(new KafkaSpoutRetryExponentialBackoff(KafkaSpoutRetryExponentialBackoff.TimeInterval.seconds(0), KafkaSpoutRetryExponentialBackoff.TimeInterval.seconds(0),
+ maxRetries, KafkaSpoutRetryExponentialBackoff.TimeInterval.seconds(0)))
.build();
this.consumerSpy = spy(new KafkaConsumerFactoryDefault().createConsumer(spoutConfig));
this.consumerFactory = new KafkaConsumerFactory<String, String>() {
@@ -100,8 +104,8 @@ public class SingleTopicKafkaSpoutTest {
for (int i = 0; i < msgCount; i++) {
ProducerRecord<String, String> producerRecord = new ProducerRecord<>(
- topicName, Integer.toString(i),
- Integer.toString(i));
+ topicName, Integer.toString(i),
+ Integer.toString(i));
kafkaUnitRule.getKafkaUnit().sendMessage(producerRecord);
}
}
@@ -316,4 +320,26 @@ public class SingleTopicKafkaSpoutTest {
expectedReemitIds.add(capturedMessageIds.get(2));
assertThat("Expected reemits to be the 3 failed tuples", new HashSet<>(reemittedMessageIds.getAllValues()), is(expectedReemitIds));
}
+
+ @Test
+ public void shouldDropMessagesAfterMaxRetriesAreReached() throws Exception {
+ //Check that if one message fails repeatedly, the retry cap limits how many times the message can be reemitted
+ int messageCount = 1;
+ initializeSpout(messageCount);
+
+ //Emit and fail the same tuple until we've reached retry limit
+ for (int i = 0; i <= maxRetries; i++) {
+ ArgumentCaptor<KafkaSpoutMessageId> messageIdFailed = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
+ spout.nextTuple();
+ verify(collector).emit(anyString(), anyListOf(Object.class), messageIdFailed.capture());
+ KafkaSpoutMessageId msgId = messageIdFailed.getValue();
+ spout.fail(msgId);
+ assertThat("Expected message id number of failures to match the number of times the message has failed", msgId.numFails(), is(i + 1));
+ reset(collector);
+ }
+
+ //Verify that the tuple is not emitted again
+ spout.nextTuple();
+ verify(collector, never()).emit(anyString(), anyListOf(Object.class), anyObject());
+ }
}
[26/40] storm git commit: STORM-2413: Make new Kafka spout respect
tuple retry limit
Posted by ka...@apache.org.
STORM-2413: Make new Kafka spout respect tuple retry limit
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/fae07d96
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/fae07d96
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/fae07d96
Branch: refs/heads/1.1.x-branch
Commit: fae07d965753330996b7e7427b1cef32298e2086
Parents: bb908f6
Author: Stig Rohde Døssing <sd...@it-minds.dk>
Authored: Tue Mar 14 22:12:50 2017 +0100
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:50:14 2017 +0900
----------------------------------------------------------------------
.../apache/storm/kafka/spout/KafkaSpout.java | 2 +-
.../storm/kafka/spout/KafkaSpoutMessageId.java | 4 +--
.../KafkaSpoutRetryExponentialBackoff.java | 14 +++++++++
.../kafka/spout/KafkaSpoutRetryService.java | 14 +++++++--
.../test/KafkaSpoutTopologyMainNamedTopics.java | 1 -
.../src/test/resources/log4j2.xml | 32 ++++++++++++++++++++
6 files changed, 61 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/fae07d96/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
index 32542b9..58347e3 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
@@ -318,7 +318,7 @@ public class KafkaSpout<K, V> extends BaseRichSpout {
*/
private boolean emitTupleIfNotEmitted(ConsumerRecord<K, V> record) {
final TopicPartition tp = new TopicPartition(record.topic(), record.partition());
- final KafkaSpoutMessageId msgId = new KafkaSpoutMessageId(record);
+ final KafkaSpoutMessageId msgId = retryService.getMessageId(record);
if (offsetManagers.containsKey(tp) && offsetManagers.get(tp).contains(msgId)) { // has been acked
LOG.trace("Tuple for record [{}] has already been acked. Skipping", record);
} else if (emitted.contains(msgId)) { // has been emitted and it's pending ack or fail
http://git-wip-us.apache.org/repos/asf/storm/blob/fae07d96/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutMessageId.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutMessageId.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutMessageId.java
index dea57c4..a9163eb 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutMessageId.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutMessageId.java
@@ -22,8 +22,8 @@ import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.common.TopicPartition;
public class KafkaSpoutMessageId {
- private transient TopicPartition topicPart;
- private transient long offset;
+ private final transient TopicPartition topicPart;
+ private final transient long offset;
private transient int numFails = 0;
private boolean emitted; // true if the record was emitted using a form of collector.emit(...).
// false when skipping null tuples as configured by the user in KafkaSpoutConfig
http://git-wip-us.apache.org/repos/asf/storm/blob/fae07d96/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryExponentialBackoff.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryExponentialBackoff.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryExponentialBackoff.java
index 2584685..6b53779 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryExponentialBackoff.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryExponentialBackoff.java
@@ -32,6 +32,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.storm.utils.Time;
/**
@@ -292,6 +293,19 @@ public class KafkaSpoutRetryExponentialBackoff implements KafkaSpoutRetryService
return count;
}
+ @Override
+ public KafkaSpoutMessageId getMessageId(ConsumerRecord<?, ?> record) {
+ KafkaSpoutMessageId msgId = new KafkaSpoutMessageId(record);
+ if (toRetryMsgs.contains(msgId)) {
+ for (KafkaSpoutMessageId originalMsgId : toRetryMsgs) {
+ if (originalMsgId.equals(msgId)) {
+ return originalMsgId;
+ }
+ }
+ }
+ return msgId;
+ }
+
// if value is greater than Long.MAX_VALUE it truncates to Long.MAX_VALUE
private long nextTime(KafkaSpoutMessageId msgId) {
final long currentTimeNanos = Time.nanoTime();
http://git-wip-us.apache.org/repos/asf/storm/blob/fae07d96/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryService.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryService.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryService.java
index f0230c3..5147752 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryService.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryService.java
@@ -23,7 +23,7 @@ import org.apache.kafka.common.TopicPartition;
import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
-import java.util.Set;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
/**
* Represents the logic that manages the retrial of failed tuples.
@@ -77,6 +77,16 @@ public interface KafkaSpoutRetryService extends Serializable {
* Returns false is this message is not scheduled for retrial
*/
boolean isScheduled(KafkaSpoutMessageId msgId);
-
+
+ /**
+ * @return The number of messages that are ready for retry
+ */
int readyMessageCount();
+
+ /**
+ * Gets the {@link KafkaSpoutMessageId} for the given record.
+ * @param record The record to fetch the id for
+ * @return The id the record was scheduled for retry with, or a new {@link KafkaSpoutMessageId} if the record was not scheduled for retry.
+ */
+ KafkaSpoutMessageId getMessageId(ConsumerRecord<?, ?> record);
}
http://git-wip-us.apache.org/repos/asf/storm/blob/fae07d96/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/test/KafkaSpoutTopologyMainNamedTopics.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/test/KafkaSpoutTopologyMainNamedTopics.java b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/test/KafkaSpoutTopologyMainNamedTopics.java
index d49516e..dc85123 100644
--- a/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/test/KafkaSpoutTopologyMainNamedTopics.java
+++ b/external/storm-kafka-client/src/test/java/org/apache/storm/kafka/spout/test/KafkaSpoutTopologyMainNamedTopics.java
@@ -46,7 +46,6 @@ public class KafkaSpoutTopologyMainNamedTopics {
private static final String TOPIC_0_1_STREAM = "test_0_1_stream";
private static final String[] TOPICS = new String[]{"test","test1","test2"};
-
public static void main(String[] args) throws Exception {
new KafkaSpoutTopologyMainNamedTopics().runMain(args);
}
http://git-wip-us.apache.org/repos/asf/storm/blob/fae07d96/external/storm-kafka-client/src/test/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/test/resources/log4j2.xml b/external/storm-kafka-client/src/test/resources/log4j2.xml
new file mode 100755
index 0000000..393dd2c
--- /dev/null
+++ b/external/storm-kafka-client/src/test/resources/log4j2.xml
@@ -0,0 +1,32 @@
+<?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.
+-->
+<Configuration status="WARN">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" charset="UTF-8"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="WARN">
+ <AppenderRef ref="Console"/>
+ </Root>
+ <Logger name="org.apache.storm.kafka" level="INFO" additivity="false">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ </Loggers>
+</Configuration>
\ No newline at end of file
[36/40] storm git commit: STORM-2552: KafkaSpoutMessageId should be
serializable
Posted by ka...@apache.org.
STORM-2552: KafkaSpoutMessageId should be serializable
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/4e258ca3
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/4e258ca3
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/4e258ca3
Branch: refs/heads/1.1.x-branch
Commit: 4e258ca3b39daddf52e81cf0287813c83d04fb43
Parents: 654ad6c
Author: Prasanna Ranganathan <pr...@flipkart.com>
Authored: Wed Jun 14 17:52:57 2017 +0530
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:59:04 2017 +0900
----------------------------------------------------------------------
.../storm/kafka/spout/KafkaSpoutMessageId.java | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/4e258ca3/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutMessageId.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutMessageId.java b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutMessageId.java
index a9163eb..59a25c2 100644
--- a/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutMessageId.java
+++ b/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutMessageId.java
@@ -18,15 +18,19 @@
package org.apache.storm.kafka.spout;
+import java.io.Serializable;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.common.TopicPartition;
-public class KafkaSpoutMessageId {
- private final transient TopicPartition topicPart;
- private final transient long offset;
- private transient int numFails = 0;
- private boolean emitted; // true if the record was emitted using a form of collector.emit(...).
- // false when skipping null tuples as configured by the user in KafkaSpoutConfig
+public class KafkaSpoutMessageId implements Serializable {
+ private final TopicPartition topicPart;
+ private final long offset;
+ private int numFails = 0;
+ /**
+ * true if the record was emitted using a form of collector.emit(...). false
+ * when skipping null tuples as configured by the user in KafkaSpoutConfig
+ */
+ private boolean emitted;
public KafkaSpoutMessageId(ConsumerRecord<?, ?> consumerRecord) {
this(consumerRecord, true);
[14/40] storm git commit: [STORM-2467] Use explicit charset when
decoding from array backed buffer
Posted by ka...@apache.org.
[STORM-2467] Use explicit charset when decoding from array backed buffer
We had the case that this broke encoding for us because it used the default
system locale. Given the fact that this code uses an explicit encoding for the
other case and that it evolved from something that always used an explicit
encoding I believe this is more correct.
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/cf4d9e1e
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/cf4d9e1e
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/cf4d9e1e
Branch: refs/heads/1.1.x-branch
Commit: cf4d9e1eb6f8d75092527255e3ff21c23d354ac1
Parents: d887036
Author: Marcus Thiesen <mt...@hubrick.com>
Authored: Tue Apr 11 10:02:38 2017 +0200
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jun 29 16:32:37 2017 +0900
----------------------------------------------------------------------
.../storm-kafka/src/jvm/org/apache/storm/kafka/StringScheme.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/cf4d9e1e/external/storm-kafka/src/jvm/org/apache/storm/kafka/StringScheme.java
----------------------------------------------------------------------
diff --git a/external/storm-kafka/src/jvm/org/apache/storm/kafka/StringScheme.java b/external/storm-kafka/src/jvm/org/apache/storm/kafka/StringScheme.java
index e2a2c22..b0b8d27 100644
--- a/external/storm-kafka/src/jvm/org/apache/storm/kafka/StringScheme.java
+++ b/external/storm-kafka/src/jvm/org/apache/storm/kafka/StringScheme.java
@@ -38,7 +38,7 @@ public class StringScheme implements Scheme {
public static String deserializeString(ByteBuffer string) {
if (string.hasArray()) {
int base = string.arrayOffset();
- return new String(string.array(), base + string.position(), string.remaining());
+ return new String(string.array(), base + string.position(), string.remaining(), UTF8_CHARSET);
} else {
return new String(Utils.toByteArray(string), UTF8_CHARSET);
}