forked from real-logic/aeron
-
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.
[Java]: move aeron client liveness to millis. Use eol indication for …
…client timeout for counters, pubs, and subs. Add heartbeat status indicator for each client to stats.
- Loading branch information
1 parent
b9422bf
commit c3b0415
Showing
7 changed files
with
166 additions
and
33 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
aeron-client/src/main/java/io/aeron/status/HeartbeatStatus.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,81 @@ | ||
/* | ||
* Copyright 2014-2018 Real Logic Ltd. | ||
* | ||
* 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 io.aeron.status; | ||
|
||
import org.agrona.MutableDirectBuffer; | ||
import org.agrona.concurrent.status.AtomicCounter; | ||
import org.agrona.concurrent.status.CountersManager; | ||
|
||
import static org.agrona.BitUtil.SIZE_OF_LONG; | ||
|
||
/** | ||
* Allocate a counter for tracking the last heartbeat of an entity. | ||
*/ | ||
public class HeartbeatStatus | ||
{ | ||
/** | ||
* Offset in the key meta data for the registration id of the counter. | ||
*/ | ||
public static final int REGISTRATION_ID_OFFSET = 0; | ||
|
||
/** | ||
* Allocate a counter for tracking the last heartbeat of an entity. | ||
* | ||
* @param tempBuffer to be used for labels and key. | ||
* @param name of the counter for the label. | ||
* @param typeId of the counter for classification. | ||
* @param countersManager from which to allocated the underlying storage. | ||
* @param registrationId to be associated with the counter. | ||
* @return a new {@link AtomicCounter} for tracking the last heartbeat. | ||
*/ | ||
public static AtomicCounter allocate( | ||
final MutableDirectBuffer tempBuffer, | ||
final String name, | ||
final int typeId, | ||
final CountersManager countersManager, | ||
final long registrationId) | ||
{ | ||
return new AtomicCounter( | ||
countersManager.valuesBuffer(), | ||
allocateCounterId(tempBuffer, name, typeId, countersManager, registrationId), | ||
countersManager); | ||
} | ||
|
||
public static int allocateCounterId( | ||
final MutableDirectBuffer tempBuffer, | ||
final String name, | ||
final int typeId, | ||
final CountersManager countersManager, | ||
final long registrationId) | ||
{ | ||
tempBuffer.putLong(REGISTRATION_ID_OFFSET, registrationId); | ||
final int keyLength = REGISTRATION_ID_OFFSET + SIZE_OF_LONG; | ||
|
||
int labelLength = 0; | ||
labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, name); | ||
labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, ": "); | ||
labelLength += tempBuffer.putLongAscii(keyLength + labelLength, registrationId); | ||
|
||
return countersManager.allocate( | ||
typeId, | ||
tempBuffer, | ||
0, | ||
keyLength, | ||
tempBuffer, | ||
keyLength, | ||
labelLength); | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
aeron-driver/src/main/java/io/aeron/driver/status/ClientHeartbeatStatus.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,42 @@ | ||
/* | ||
* Copyright 2014-2018 Real Logic Ltd. | ||
* | ||
* 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 io.aeron.driver.status; | ||
|
||
import io.aeron.status.HeartbeatStatus; | ||
import org.agrona.MutableDirectBuffer; | ||
import org.agrona.concurrent.status.AtomicCounter; | ||
import org.agrona.concurrent.status.CountersManager; | ||
|
||
public class ClientHeartbeatStatus | ||
{ | ||
/** | ||
* Type id of an Aeron client heartbeat status indicator. | ||
*/ | ||
public static final int CLIENT_HEARTBEAT_TYPE_ID = 11; | ||
|
||
/** | ||
* Human readable name for the counter. | ||
*/ | ||
public static final String NAME = "client-heartbeat"; | ||
|
||
public static AtomicCounter allocate( | ||
final MutableDirectBuffer tempBuffer, | ||
final CountersManager countersManager, | ||
final long registrationId) | ||
{ | ||
return HeartbeatStatus.allocate(tempBuffer, NAME, CLIENT_HEARTBEAT_TYPE_ID, countersManager, registrationId); | ||
} | ||
} |