Skip to content

[STORM-1015] Allow Kafka offsets to be saved using Kafka's consumer offset management api - #705

Closed
ooasis wants to merge 19 commits into
apache:masterfrom
ooasis:kafka-storage
Closed

[STORM-1015] Allow Kafka offsets to be saved using Kafka's consumer offset management api#705
ooasis wants to merge 19 commits into
apache:masterfrom
ooasis:kafka-storage

Conversation

@ooasis

Copy link
Copy Markdown

Not sure when it will be reviewed. So I chose to implement it based on master branch. Could be ported to other branches if needed.

-thanks

@rmkellogg

Copy link
Copy Markdown
Contributor

A few minor nits:

When providing javadoc on variables/methods, be sure to use the following syntax:

/**
* Comment text
**/
private String variableName;

Instead of the following:

// offset state information storage. validate options are storm and kafka
private String variableName;

The first variation will provide fly-over-help within IDE and generated Javadoc files.

Secondly:
Logger instance variables should be private.

Thirdly:
Suggest instance variables on PartitionManager, StaticCoordinator ZkDataStore be made private.

@ooasis

Copy link
Copy Markdown
Author

Thanks for the advices. Will get them fixed as soon as I get some time.

@sweetest

Copy link
Copy Markdown
Contributor

how will this change affect the format of spout's offset message in zookeeper?

@ooasis

Copy link
Copy Markdown
Author

I assume you are referring to the json format of the spout "state" stored in ZK? The "state" will be saved using the exact same json format in Kafka's internal topic as the "metadata" associated with the offsets.

@ooasis

Copy link
Copy Markdown
Author

Fixed coding styles suggested by rmkellogg.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please expand this * import to explicitly include the classes you depend on

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is pushed

@erikdw

Copy link
Copy Markdown
Contributor

This seems like it might not be backwards compatible with the existing kafka-spout; i.e., the offsets in ZK are presumably not going to be stored exactly the same as they were before. Is there any plan for supporting migration from the current kafka-spout to this one?

@erikdw

Copy link
Copy Markdown
Contributor

Furthermore, can you please provide a reference to "Kafka's consumer offset management api" in your description?

@ooasis

Copy link
Copy Markdown
Author

Erik,

I added 2 reference links in the description with more information on "Kafka's consumer offset management api".

As of migration from existing offsets stored in ZK to Kafka, it could be done with a simple migration utility similar to the tools provided by Kafka (https://cwiki.apache.org/confluence/display/KAFKA/System+Tools). Question is where it belongs to in Storm codebase.

-thanks

Comment threadexternal/storm-kafka/README.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: Zookeeper -> ZooKeeper.

@erikdw

Copy link
Copy Markdown
Contributor

@hsun-cnnxty : I don't see the reference links in the Description on the PR's Conversation view? Maybe I'm looking in the wrong place? Maybe they should be in comments in the code too?
Yup, was looking in the wrong place, I didn't realize that "the description" meant the JIRA issue's Description!

I'm guessing the following are the links you meant to put:

I just want it to be very clear that this PR's purpose is to change from the kafka spout's consumer offsets being stored in ZooKeeper, to instead being stored directly in Kafka. We should also be clear about the version of Kafka required for such support (0.8.2+). I know the current version of the storm-kafka pom.xml (as of this change) is already referencing 0.8.2.1, but I feel like it should be called out as an explicit requirement in the commit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: original

@ooasis

Copy link
Copy Markdown
Author

Erik,

Pushed the change to rename config from "storm" to "zookeeper" (also fixed the typo). As of Kafka dependency, it is a good question. Actually I am not clear on how the "storm-kafka" module is built with Maven. Without adding the particular Kafka dependencies in pom.xml, the local build just won't work for me. Do I suppose to use some external config (such as settings.xml) to make it built locally?

-thanks

@choang

Copy link
Copy Markdown

I recommend making your abstraction at the state store, so you would have:

public interface StateStore {
public void write(Partition p, long offset);
public long read(Partition p);
}
public class ZkStateStore implements StateStore {
...
}
public class KafkaStateStore implements StateStore {
...
}
/**
Some topologies read from LATEST after a restart, so only memory state is needed.
*/
public class MemoryStateStore implements StateStore {
...
}

You would not need different PartitionStateManager for different stores. You would just have:

public class PartitionStateManager {
public PartitionStateManager (..., StateStore store) { ... }
public void writeState(...) {
store.write(...);
}
}

@ooasis

Copy link
Copy Markdown
Author

Hi Chi,

Storm stores more than just offset/partition data in the "state", would it be necessary to declare?

public interface StateStore {
public void write(Partition p, Map<Object, Object> state);
public Map<Object, Object> state read(Partition p);
}

-thanks

@choang

Copy link
Copy Markdown

I would make state more concrete, but I suppose your approach is fine.

@erikdw

Copy link
Copy Markdown
Contributor

@hsun-cnnxty : can you please make your statement a bit more concrete? i.e., what other info is stored in a given kafka topic's consumer state? (other than the offset/partition)

@ooasis

Copy link
Copy Markdown
Author

@choang: the refactored code is pushed

@erikdw: I was referring to the internal Json structure used to store offsets as shown by example below:

{
"broker": {
"host": "kafka.sample.net",
"port": 9092
},
"offset": 4285,
"partition": 1,
"topic": "testTopic",
"topology": {
"id": "fce905ff-25e0 -409e-bc3a-d855f 787d13b",
"name": "Test Topology"
}
}

Comment threadexternal/storm-kafka/README.md Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a mechanism/section in the release notes to call out this change? changing this var name would break existing code.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of a factory, you can make the developer declare the StateStore:

public void createTopology() {
Spout spout = new KafkaSpout(..., new KafkaStateStore(...));
...
}

This should keep the KafkaSpout code much simpler and more explicit, and eliminate the need for a factory.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stormConf isn't used so remove. By using spoutConfig, you are bleeding the spout state into the store. I understand it is for convenience, but using explicit would be better, so perhaps you can create a KafkaStoreConfig.

@choang

Copy link
Copy Markdown

looks really good. just had a few nits that shouldn't block. I also don't have a vote, so you'll need to find a proper reviewer :)

@ooasis

Copy link
Copy Markdown
Author

@choang thanks for the code review. Your comment on sharing the kafka store for all partitions is really helpful and I was able to cleanup a lot of unnecessary logic. I still have some code to check in and need to run a few tests. Maybe you can hold on for a while as I don't want to waste your time on the changing code base. I will try to write a response as soon as I get some time. Thanks again.

@ooasis

Copy link
Copy Markdown
Author

@choang In recent changes, I have made it possible to plug in custom store implementations. The custom implementation is given the opportunity to initialize itself by injecting two configuration objects into the constructor which takes the form like

public MyStoreImpl(Map conf, SpoutConfig spoutConfig)

In addition, I feel it is better to keep the implementation specific details, such as zookeeper quorum, inside the store implementation instead of leaving it to external class to build a implementation specific configuration object such as KafkaStoreConfig. What do you think?

Thanks again for the code review.

@choang

Copy link
Copy Markdown

StateStore implementations could be designed like:

public class KafkaStateStore implements StateStore {
public KafkaStateStore(HostPort kafkaBroker, String consumerId) { // consumerId could be topic? I'm don't know enough about the compaction feature
...
}
...
}
public class ZkStateStore implements StateStore {
public ZkStateStore(HostPort zkConnect, String path) {
...
}
}
// future implementations
public class JdbcStateStore implements StateStore {
public JdbcStateStore(String url, String stateTable, String user, String password) {
...
}
}
public class MemoryStateStore implements StateStore {
public MemoryStateStore() {
...
}
}

What I'm trying to illustrate are two factors:

  1. go away from StormConf and SpoutConfig because StateStore does not need all properties of either objects.
  2. the concrete implements of StateStore do not need to have the same constructor because your goal is not to have a factory and make it completely config driven. You want to make it so the topology developer can decide what StateStore to use.

With the above, it would be pretty easy for someone to implement MemoryStateStore and JdbcStateStore.

* apache/master: (21 commits)
Added STORM-1204 to Changelog
Added STORM-831 to Changelog
Added STORM-1208 to Changelog
Guard against both Infinity and NaN
Added STORM-1016 to Changelog
add apache license header
Guard against NPE, and avoid using NaN values
Fixing attempt to access to directory before checking user authorization and avoid dumps listing error
Fix copyright year and holder.
Adding MIT license for statistics image
Added STORM-1190 to Changelog
replace HashSet with LinkedHashSet in TridentTopology.java
Use generic name bugtracker instead of jira and use public domain images
Some more fixes to the test so they shutdown correctly.
Fixes for unit tests getting stuck.
Some fixes to improve performance
Better performance with batching disabled, and better CPU utilization from flushers
STORM-1190: System Load too high after recent changes
STORM-1016: Generate trident bolt ids with sorted group names
Remove default JIRA URL so that custom deployments won't default to apache jira link
...
@ooasis

Copy link
Copy Markdown
Author

@choang changes are made and latest code from master merged in. Please review whenever you have time. -thanks

@choang

Copy link
Copy Markdown

this looks good enough

* apache/master: (64 commits)
add STORM-1496 to CHANGELOG.md
fixing sporadic nimbus log failure and topology visualization
backport STORM-1484/1478 to 1.0.0, too
add STORM-1499 to CHANGELOG.md
fix wrong package name for storm trident
Added STORM-1463 to Changelog
Added STORM-1485 to Changelog
Added STORM-1486 to Changelog
Added STORM-1214 to Changelog
[STORM-1486] Fix storm-kafa documentation
CHANGELOG: move STORM-1450 to 1.0.0 (backported)
CHANGELOG.md: move 0.10.0-beta2 to 0.10.0
Fix CHANGELOG.md to have 0.10.1 and move issues
Fix misplaced CHANGELOGs
add STORM-1452 to changelog
add STORM-1406 to changelog
adds comments about licensing the profiler feature
Fixes profiling/debugging out of the box
add storm-mqtt to binary distribution
Fixing minor code comments
...
@AwesomeJohnR

Copy link
Copy Markdown

Any updates on the status of this merge? This update would be very helpful

@ooasis

Copy link
Copy Markdown
Author

Just did another merge to keep it up to date with master branch. Not sure what the plan is now. I would be happy to make any changes that can help to make the final merge happen.

d2r pushed a commit to d2r/storm that referenced this pull request Oct 16, 2018
We are closing stale Pull Requests to make the list more manageable.
Please re-open any Pull Request that has been closed in error.
Closesapache#608Closesapache#639Closesapache#640Closesapache#648Closesapache#662Closesapache#668Closesapache#692Closesapache#705Closesapache#724Closesapache#728Closesapache#730Closesapache#753Closesapache#803Closesapache#854Closesapache#922Closesapache#986Closesapache#992Closesapache#1019Closesapache#1040Closesapache#1041Closesapache#1043Closesapache#1046Closesapache#1051Closesapache#1078Closesapache#1146Closesapache#1164Closesapache#1165Closesapache#1178Closesapache#1213Closesapache#1225Closesapache#1258Closesapache#1259Closesapache#1268Closesapache#1272Closesapache#1277Closesapache#1278Closesapache#1288Closesapache#1296Closesapache#1328Closesapache#1342Closesapache#1353Closesapache#1370Closesapache#1376Closesapache#1391Closesapache#1395Closesapache#1399Closesapache#1406Closesapache#1410Closesapache#1422Closesapache#1427Closesapache#1443Closesapache#1462Closesapache#1468Closesapache#1483Closesapache#1506Closesapache#1509Closesapache#1515Closesapache#1520Closesapache#1521Closesapache#1525Closesapache#1527Closesapache#1544Closesapache#1550Closesapache#1566Closesapache#1569Closesapache#1570Closesapache#1575Closesapache#1580Closesapache#1584Closesapache#1591Closesapache#1600Closesapache#1611Closesapache#1613Closesapache#1639Closesapache#1703Closesapache#1711Closesapache#1719Closesapache#1737Closesapache#1760Closesapache#1767Closesapache#1768Closesapache#1785Closesapache#1799Closesapache#1822Closesapache#1824Closesapache#1844Closesapache#1874Closesapache#1918Closesapache#1928Closesapache#1937Closesapache#1942Closesapache#1951Closesapache#1957Closesapache#1963Closesapache#1964Closesapache#1965Closesapache#1967Closesapache#1968Closesapache#1971Closesapache#1985Closesapache#1986Closesapache#1998Closesapache#2031Closesapache#2032Closesapache#2071Closesapache#2076Closesapache#2108Closesapache#2119Closesapache#2128Closesapache#2142Closesapache#2174Closesapache#2206Closesapache#2297Closesapache#2322Closesapache#2332Closesapache#2341Closesapache#2377Closesapache#2414Closesapache#2469
d2r pushed a commit to d2r/storm that referenced this pull request Oct 16, 2018
We are closing stale Pull Requests to make the list more manageable.
Please re-open any Pull Request that has been closed in error.
Closesapache#608Closesapache#639Closesapache#640Closesapache#648Closesapache#662Closesapache#668Closesapache#692Closesapache#705Closesapache#724Closesapache#728Closesapache#730Closesapache#753Closesapache#803Closesapache#854Closesapache#922Closesapache#986Closesapache#992Closesapache#1019Closesapache#1040Closesapache#1041Closesapache#1043Closesapache#1046Closesapache#1051Closesapache#1078Closesapache#1146Closesapache#1164Closesapache#1165Closesapache#1178Closesapache#1213Closesapache#1225Closesapache#1258Closesapache#1259Closesapache#1268Closesapache#1272Closesapache#1277Closesapache#1278Closesapache#1288Closesapache#1296Closesapache#1328Closesapache#1342Closesapache#1353Closesapache#1370Closesapache#1376Closesapache#1391Closesapache#1395Closesapache#1399Closesapache#1406Closesapache#1410Closesapache#1422Closesapache#1427Closesapache#1443Closesapache#1462Closesapache#1468Closesapache#1483Closesapache#1506Closesapache#1509Closesapache#1515Closesapache#1520Closesapache#1521Closesapache#1525Closesapache#1527Closesapache#1544Closesapache#1550Closesapache#1566Closesapache#1569Closesapache#1570Closesapache#1575Closesapache#1580Closesapache#1584Closesapache#1591Closesapache#1600Closesapache#1611Closesapache#1613Closesapache#1639Closesapache#1703Closesapache#1711Closesapache#1719Closesapache#1737Closesapache#1760Closesapache#1767Closesapache#1768Closesapache#1785Closesapache#1799Closesapache#1822Closesapache#1824Closesapache#1844Closesapache#1874Closesapache#1918Closesapache#1928Closesapache#1937Closesapache#1942Closesapache#1951Closesapache#1957Closesapache#1963Closesapache#1964Closesapache#1965Closesapache#1967Closesapache#1968Closesapache#1971Closesapache#1985Closesapache#1986Closesapache#1998Closesapache#2031Closesapache#2032Closesapache#2071Closesapache#2076Closesapache#2108Closesapache#2119Closesapache#2128Closesapache#2142Closesapache#2174Closesapache#2206Closesapache#2297Closesapache#2322Closesapache#2332Closesapache#2341Closesapache#2377Closesapache#2414Closesapache#2469
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@ooasis@rmkellogg@sweetest@erikdw@choang@AwesomeJohnR@cm-cnnxty