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-615: Auto-migrate Kafka checkpoints into coordinator stream
Squashed commit of the following: commit ea64b4e9da0c68849d79353121d2577d27feb709 Author: Yi Pan (Data Infrastructure) <[email protected]> Date: Tue Sep 22 14:25:52 2015 -0700 SAMZA-615: Fix unit test in TestJobRunner since there is no guaranteed execution ordering between two tests commit 3d9d897c152818993c426b00ceed755690baf5d1 Author: Yi Pan (Data Infrastructure) <[email protected]> Date: Tue Sep 22 11:11:40 2015 -0700 SAMZA-615: Merged w/ SAMZA-731 and removed all write operations in KafkaCheckpointManager commit 4d35dc84614374f6efdb911cb9ca7ce18b1f2c76 Author: Yi Pan (Data Infrastructure) <[email protected]> Date: Wed Sep 16 13:37:11 2015 -0700 SAMZA-615: Add auto-checkpoint migration for Kafka checkpoints
- Loading branch information
Showing
19 changed files
with
1,383 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...e/src/main/java/org/apache/samza/coordinator/stream/messages/SetMigrationMetaMessage.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,51 @@ | ||
/* | ||
* 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.coordinator.stream.messages; | ||
/** | ||
* The Set is used to store the migrations that have been performed | ||
* The structure looks like: | ||
* { | ||
* Key: migration-info | ||
* Type: set-migration-info | ||
* Source: ContainerID | ||
* MessageMap: | ||
* { | ||
* "0910checkpointmigration" : true | ||
* } | ||
* } | ||
*/ | ||
public class SetMigrationMetaMessage extends CoordinatorStreamMessage { | ||
public static final String TYPE = "set-migration-info"; | ||
|
||
public SetMigrationMetaMessage(CoordinatorStreamMessage message) { | ||
super(message.getKeyArray(), message.getMessageMap()); | ||
} | ||
|
||
public SetMigrationMetaMessage(String source, String metaInfoKey, String metaInfoVal) { | ||
super(source); | ||
setType(TYPE); | ||
setKey("migration-info"); | ||
putMessageValue(metaInfoKey, metaInfoVal); | ||
} | ||
|
||
public String getMetaInfo(String metaInfoKey) { | ||
return getMessageValues().get(metaInfoKey); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
samza-core/src/main/java/org/apache/samza/migration/MigrationPlan.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,27 @@ | ||
/* | ||
* 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.migration; | ||
|
||
import org.apache.samza.config.Config; | ||
|
||
|
||
public interface MigrationPlan { | ||
void migrate(Config config); | ||
} |
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
52 changes: 52 additions & 0 deletions
52
samza-core/src/main/scala/org/apache/samza/migration/JobRunnerMigration.scala
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,52 @@ | ||
/* | ||
* 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.migration | ||
|
||
import org.apache.samza.config.Config | ||
import org.apache.samza.util.{Util, Logging} | ||
import org.apache.samza.SamzaException | ||
|
||
|
||
object JobRunnerMigration { | ||
val CHECKPOINTMIGRATION = "old.checkpoint.KafkaCheckpointMigration" | ||
def apply(config: Config) = { | ||
val migration = new JobRunnerMigration | ||
migration.checkpointMigration(config) | ||
} | ||
} | ||
|
||
class JobRunnerMigration extends Logging { | ||
|
||
def checkpointMigration(config: Config) = { | ||
val checkpointFactory = Option(config.get("task.checkpoint.factory")) | ||
checkpointFactory match { | ||
case Some("org.apache.samza.checkpoint.kafka.KafkaCheckpointManagerFactory") => | ||
info("Performing checkpoint migration") | ||
val checkpointMigrationPlan = Util.getObj[MigrationPlan](JobRunnerMigration.CHECKPOINTMIGRATION) | ||
checkpointMigrationPlan.migrate(config) | ||
case None => | ||
info("No task.checkpoint.factory defined, not performing any checkpoint migration") | ||
case _ => | ||
val errorMsg = "Auto checkpoint migration for 0.10.0 upgrade is only supported for Kafka checkpointing system, " + | ||
"for everything else, please use the checkpoint tool and remove task.checkpoint.factory configuration" | ||
error(errorMsg) | ||
throw new SamzaException(errorMsg) | ||
} | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
samza-core/src/test/resources/test-migration-fail.properties
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,26 @@ | ||
# | ||
# | ||
# 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. | ||
# | ||
# | ||
|
||
job.factory.class=org.apache.samza.job.MockJobFactory | ||
job.name=test-job | ||
foo=bar | ||
systems.coordinator.samza.factory=org.apache.samza.coordinator.stream.MockCoordinatorStreamSystemFactory | ||
task.checkpoint.factory=org.apache.samza.checkpoint.file.FileSystemCheckpointManagerFactory |
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.