-
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 AsyncBuffer of KafkaSink to handle Kafka borkers failure cases, w…
…hich without blocking sender, and record failed events to logs by MissedEventHandler
- Loading branch information
beineng
committed
Oct 18, 2018
1 parent
4312495
commit 46df10d
Showing
7 changed files
with
160 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ target/ | |
/zkdata/ | ||
/native/ | ||
/integration-test/native/ | ||
hs_err_*.log | ||
hs_err_*.log | ||
.ensime* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>${EB_LOGFILE:-./log/default.log}</file> | ||
<shutdownHook/> | ||
|
||
<!-- appenders --> | ||
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>${EB_LOGFILE:-./log/default}.log</file> | ||
<append>true</append> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
<fileNamePattern>${EB_LOGFILE:-./log/default.log}.%d{yyyy-MM-dd}.%i</fileNamePattern> | ||
<timeBasedFileNamingAndTriggeringPolicy | ||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | ||
<!-- or whenever the file size reaches 50MB --> | ||
<maxFileSize>100MB</maxFileSize> | ||
</timeBasedFileNamingAndTriggeringPolicy> | ||
<!-- keep 30 days' worth of history --> | ||
<fileNamePattern>${EB_LOGFILE:-./log/default}.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
<maxHistory>30</maxHistory> | ||
<totalSizeCap>3GB</totalSizeCap> | ||
</rollingPolicy> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} %X{sourceThread} %X{akkaSource} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<appender name="ASYNC_ROLLING" class="ch.qos.logback.classic.AsyncAppender"> | ||
<appender-ref ref="ROLLING" /> | ||
</appender> | ||
|
||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} %X{sourceThread} %X{akkaSource} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="Sentry" class="io.sentry.logback.SentryAppender"> | ||
<appender name="SENTRY" class="io.sentry.logback.SentryAppender"> | ||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
<level>WARN</level> | ||
</filter> | ||
</appender> | ||
|
||
<appender name="MISSED" class="ch.qos.logback.core.FileAppender"> | ||
<file>${EB_MISSED_EVENTS_FILE:-./log/missed_events}</file> | ||
<append>true</append> | ||
<immediateFlush>true</immediateFlush> | ||
<encoder> | ||
<pattern>%msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="ASYNC_MISSED" class="ch.qos.logback.classic.AsyncAppender"> | ||
<appender-ref ref="MISSED" /> | ||
<queueSize>256</queueSize> | ||
<maxFlushTime>0</maxFlushTime> | ||
<discardingThreshold>0</discardingThreshold> | ||
<includeCallerData>false</includeCallerData> | ||
<neverBlock>true</neverBlock> | ||
</appender> | ||
|
||
|
||
<!-- loggers --> | ||
<root level="${EB_LOGLEVEL:-DEBUG}"> | ||
<appender-ref ref="${EB_LOGREF:-CONSOLE}" /> | ||
<appender-ref ref="SENTRY" /> | ||
</root> | ||
|
||
<logger name="org.apache.kafka" level="INFO" /> | ||
<logger name="org.apache.zookeeper" level="INFO" /> | ||
<logger name="com.datastax.driver.core.Connection" level="INFO" /> | ||
|
||
<root level="${EB_LOGLEVEL:-DEBUG}"> | ||
<appender-ref ref="${EB_LOGREF:-STDOUT}" /> | ||
<appender-ref ref="Sentry" /> | ||
</root> | ||
<logger name="com.thenetcircle.event_bus.misc.MissedEventHandler" additivity="false"> | ||
<appender-ref ref="ASYNC_MISSED" /> | ||
</logger> | ||
|
||
</configuration> |
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
28 changes: 28 additions & 0 deletions
28
core/src/main/scala/com/thenetcircle/event_bus/misc/MissedEventHandler.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,28 @@ | ||
/* | ||
* 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. | ||
* | ||
* Contributors: | ||
* Beineng Ma <[email protected]> | ||
*/ | ||
|
||
package com.thenetcircle.event_bus.misc | ||
|
||
import com.thenetcircle.event_bus.interfaces.Event | ||
import com.typesafe.scalalogging.StrictLogging | ||
|
||
object MissedEventHandler extends StrictLogging { | ||
|
||
def handle(event: Event): Unit = | ||
logger.warn(event.body.data) | ||
|
||
} |
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