forked from spring-projects/spring-integration
-
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.
INT-3617: ZK Leader Event Processing
JIRA: https://jira.spring.io/browse/INT-3617 Start/stop `SmartLifecyle` beans with leader election/revocation. ZK Namespace Support Add Annotation Support INT-3617: Polishing Add `SmartLifecycle` to listener parser. INT-3617: Polishing; PR Comments Revert SmartLifecycleRoleController Remove reflection. Remove Dependence on spring-cloud-cluster Temporarily move the relevant classes here. Polishing; PR Comments and Fix Test Test was incorrectly stopping the LeaderInitiator before it was elected. Set auto-startup="false" in the i-c-a so we wait for its start before stopping the LeaderInitiator. Fix JavaDocs
- Loading branch information
1 parent
9cc0652
commit 814698f
Showing
42 changed files
with
1,829 additions
and
12 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
44 changes: 44 additions & 0 deletions
44
spring-integration-core/src/main/java/org/springframework/integration/annotation/Role.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,44 @@ | ||
/* | ||
* Copyright 2002-2015 the original author or authors. | ||
* | ||
* 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.springframework.integration.annotation; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Annotate endpoints to assign them to a role. Such endpoints can be started/stopped as | ||
* a group. See {@code SmartLifecycleRoleController}. | ||
* | ||
* @author Gary Russell | ||
* @since 4.2 | ||
*/ | ||
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Inherited | ||
@Documented | ||
public @interface Role { | ||
|
||
/** | ||
* @return the role for this endpoint. See {@code SmartLifecycleRoleController}. | ||
*/ | ||
String value() default ""; | ||
|
||
} |
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
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
70 changes: 70 additions & 0 deletions
70
...egration-core/src/main/java/org/springframework/integration/leader/AbstractCandidate.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,70 @@ | ||
/* | ||
* Copyright 2015 the original author or authors. | ||
* | ||
* 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.springframework.integration.leader; | ||
|
||
import java.util.UUID; | ||
|
||
import org.springframework.util.StringUtils; | ||
|
||
/** | ||
* Base implementation of a {@link Candidate}. | ||
* | ||
* @author Janne Valkealahti | ||
* | ||
*/ | ||
public abstract class AbstractCandidate implements Candidate { | ||
|
||
private static final String DEFAULT_ROLE = "leader"; | ||
|
||
private final String id; | ||
|
||
private final String role; | ||
|
||
/** | ||
* Instantiate a abstract candidate. | ||
*/ | ||
public AbstractCandidate() { | ||
this(null, null); | ||
} | ||
|
||
/** | ||
* Instantiate a abstract candidate. | ||
* | ||
* @param id the identifier | ||
* @param role the role | ||
*/ | ||
public AbstractCandidate(String id, String role) { | ||
this.id = StringUtils.hasText(id) ? id : UUID.randomUUID().toString(); | ||
this.role = StringUtils.hasText(role) ? role : DEFAULT_ROLE; | ||
} | ||
|
||
@Override | ||
public String getRole() { | ||
return this.role; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return this.id; | ||
} | ||
|
||
@Override | ||
public abstract void onGranted(Context ctx) throws InterruptedException; | ||
|
||
@Override | ||
public abstract void onRevoked(Context ctx); | ||
|
||
} |
Oops, something went wrong.