forked from apache/samza
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAMZA-123: Move topic partition grouping to the AM and generalize
- Loading branch information
Showing
65 changed files
with
2,335 additions
and
857 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,5 @@ build | |
samza-test/state | ||
docs/learn/documentation/0.7.0/api/javadocs | ||
.DS_Store | ||
out/ | ||
*.patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
samza-api/src/main/java/org/apache/samza/container/SystemStreamPartitionGrouper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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.samza.container; | ||
|
||
import org.apache.samza.system.SystemStreamPartition; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** | ||
* Group a set of SystemStreamPartitions into logical taskNames that share a common characteristic, defined | ||
* by the implementation. Each taskName has a key that uniquely describes what sets may be in it, but does | ||
* not generally enumerate the elements of those sets. For example, a SystemStreamPartitionGrouper that | ||
* groups SystemStreamPartitions (each with 4 partitions) by their partition, would end up generating | ||
* four TaskNames: 0, 1, 2, 3. These TaskNames describe the partitions but do not list all of the | ||
* SystemStreamPartitions, which allows new SystemStreamPartitions to be added later without changing | ||
* the definition of the TaskNames, assuming these new SystemStreamPartitions do not have more than | ||
* four partitions. On the other hand, a SystemStreamPartitionGrouper that wanted each SystemStreamPartition | ||
* to be its own, unique group would use the SystemStreamPartition's entire description to generate | ||
* the TaskNames. | ||
*/ | ||
public interface SystemStreamPartitionGrouper { | ||
public Map<TaskName, Set<SystemStreamPartition>> group(Set<SystemStreamPartition> ssps); | ||
} |
28 changes: 28 additions & 0 deletions
28
samza-api/src/main/java/org/apache/samza/container/SystemStreamPartitionGrouperFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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.samza.container; | ||
|
||
import org.apache.samza.config.Config; | ||
|
||
/** | ||
* Return an instance a SystemStreamPartitionGrouper per the particular implementation | ||
*/ | ||
public interface SystemStreamPartitionGrouperFactory { | ||
public SystemStreamPartitionGrouper getSystemStreamPartitionGrouper(Config config); | ||
} |
63 changes: 63 additions & 0 deletions
63
samza-api/src/main/java/org/apache/samza/container/TaskName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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.samza.container; | ||
|
||
/** | ||
* A unique identifier of a set of a SystemStreamPartitions that have been grouped by | ||
* a {@link org.apache.samza.container.SystemStreamPartitionGrouper}. The | ||
* SystemStreamPartitionGrouper determines the TaskName for each set it creates. | ||
*/ | ||
public class TaskName implements Comparable<TaskName> { | ||
private final String taskName; | ||
|
||
public String getTaskName() { | ||
return taskName; | ||
} | ||
|
||
public TaskName(String taskName) { | ||
this.taskName = taskName; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
TaskName taskName1 = (TaskName) o; | ||
|
||
if (!taskName.equals(taskName1.taskName)) return false; | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return taskName.hashCode(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return taskName; | ||
} | ||
|
||
@Override | ||
public int compareTo(TaskName that) { | ||
return taskName.compareTo(that.taskName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.