forked from sofastack/sofa-jraft
-
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.
add shared raft timer, default false (sofastack#414)
* add shared raft timer, default false * more robust * add shared scheduler * clear necessary code * minor change * fix unit test * add channel init low/high write buf water mark for bolt impl * minor fix * minor fix for CR
- Loading branch information
1 parent
c924b49
commit 5d47497
Showing
35 changed files
with
1,044 additions
and
166 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
88 changes: 88 additions & 0 deletions
88
jraft-core/src/main/java/com/alipay/sofa/jraft/core/Scheduler.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,88 @@ | ||
/* | ||
* 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 com.alipay.sofa.jraft.core; | ||
|
||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* | ||
* @author jiachun.fjc | ||
*/ | ||
public interface Scheduler { | ||
|
||
/** | ||
* Creates and executes a one-shot action that becomes enabled | ||
* after the given delay. | ||
* | ||
* @param command the task to execute | ||
* @param delay the time from now to delay execution | ||
* @param unit the time unit of the delay parameter | ||
* @return a ScheduledFuture representing pending completion of | ||
* the task and whose {@code get()} method will return | ||
* {@code null} upon completion | ||
* scheduled for execution | ||
*/ | ||
ScheduledFuture<?> schedule(final Runnable command, final long delay, final TimeUnit unit); | ||
|
||
/** | ||
* Creates and executes a periodic action that becomes enabled first | ||
* after the given initial delay, and subsequently with the given | ||
* period; that is executions will commence after | ||
* {@code initialDelay} then {@code initialDelay+period}, then | ||
* {@code initialDelay + 2 * period}, and so on. | ||
* If any execution of the task | ||
* encounters an exception, subsequent executions are suppressed. | ||
* Otherwise, the task will only terminate via cancellation or | ||
* termination of the executor. If any execution of this task | ||
* takes longer than its period, then subsequent executions | ||
* may start late, but will not concurrently execute. | ||
* | ||
* @param command the task to execute | ||
* @param initialDelay the time to delay first execution | ||
* @param period the period between successive executions | ||
* @param unit the time unit of the initialDelay and period parameters | ||
* @return a ScheduledFuture representing pending completion of | ||
* the task, and whose {@code get()} method will throw an | ||
* exception upon cancellation | ||
*/ | ||
ScheduledFuture<?> scheduleAtFixedRate(final Runnable command, final long initialDelay, final long period, | ||
final TimeUnit unit); | ||
|
||
/** | ||
* Creates and executes a periodic action that becomes enabled first | ||
* after the given initial delay, and subsequently with the | ||
* given delay between the termination of one execution and the | ||
* commencement of the next. If any execution of the task | ||
* encounters an exception, subsequent executions are suppressed. | ||
* Otherwise, the task will only terminate via cancellation or | ||
* termination of the executor. | ||
* | ||
* @param command the task to execute | ||
* @param initialDelay the time to delay first execution | ||
* @param delay the delay between the termination of one | ||
* execution and the commencement of the next | ||
* @param unit the time unit of the initialDelay and delay parameters | ||
* @return a ScheduledFuture representing pending completion of | ||
* the task, and whose {@code get()} method will throw an | ||
* exception upon cancellation | ||
*/ | ||
ScheduledFuture<?> scheduleWithFixedDelay(final Runnable command, final long initialDelay, final long delay, | ||
final TimeUnit unit); | ||
|
||
void shutdown(); | ||
} |
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.