forked from aeron-io/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]: moved event log to be all static and removed from MediaDriver…
….Context. Added EventLogAgent that uses event log reader thread.
- Loading branch information
1 parent
cd7dc4b
commit b396586
Showing
23 changed files
with
203 additions
and
153 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
aeron-agent/src/main/java/uk/co/real_logic/aeron/agent/EventLogAgent.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,58 @@ | ||
/* | ||
* Copyright 2014 - 2016 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 uk.co.real_logic.aeron.agent; | ||
|
||
import uk.co.real_logic.aeron.driver.event.EventConfiguration; | ||
import uk.co.real_logic.agrona.concurrent.AgentRunner; | ||
import uk.co.real_logic.agrona.concurrent.SleepingIdleStrategy; | ||
|
||
import java.lang.instrument.Instrumentation; | ||
|
||
public class EventLogAgent | ||
{ | ||
private static final EventLogReaderAgent EVENT_LOG_READER_AGENT = new EventLogReaderAgent(); | ||
|
||
private static final AgentRunner EVENT_LOG_READER_AGENT_RUNNER = | ||
new AgentRunner(new SleepingIdleStrategy(1), EventLogAgent::errorHandler, null, EVENT_LOG_READER_AGENT); | ||
|
||
private static final Thread EVENT_LOG_READER_THREAD = new Thread(EVENT_LOG_READER_AGENT_RUNNER); | ||
|
||
public static void errorHandler(final Throwable throwable) | ||
{ | ||
} | ||
|
||
public static void premain(final String agentArgs, final Instrumentation instrumentation) | ||
{ | ||
if (EventConfiguration.ENABLED_EVENT_CODES != 0) | ||
{ | ||
/* | ||
* Intercept based on enabled events: | ||
* SenderProxy | ||
* ClientProxy | ||
* DriverCondcutor (onClientCommand) | ||
* SendChannelEndpoint | ||
* ReceiveChannelEndpoint | ||
*/ | ||
|
||
EVENT_LOG_READER_THREAD.setName("event log reader"); | ||
EVENT_LOG_READER_THREAD.start(); | ||
} | ||
} | ||
|
||
public static void agentmain(final String agentArgs, final Instrumentation instrumentation) | ||
{ | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
aeron-agent/src/main/java/uk/co/real_logic/aeron/agent/EventLogReaderAgent.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 2014 - 2016 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 uk.co.real_logic.aeron.agent; | ||
|
||
import uk.co.real_logic.aeron.driver.event.EventCode; | ||
import uk.co.real_logic.aeron.driver.event.EventConfiguration; | ||
import uk.co.real_logic.agrona.concurrent.Agent; | ||
import uk.co.real_logic.agrona.concurrent.MessageHandler; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public class EventLogReaderAgent implements Agent | ||
{ | ||
final Consumer<String> eventConsumer = System.out::println; | ||
final MessageHandler onEventFunc = | ||
(typeId, buffer, offset, length) -> eventConsumer.accept(EventCode.get(typeId).decode(buffer, offset)); | ||
|
||
public int doWork() throws Exception | ||
{ | ||
return EventConfiguration.EVENT_RING_BUFFER.read(onEventFunc, EventConfiguration.EVENT_READER_FRAME_LIMIT); | ||
} | ||
|
||
public String roleName() | ||
{ | ||
return null; | ||
} | ||
|
||
public void onClose() | ||
{ | ||
} | ||
} |
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
Oops, something went wrong.