-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial refactoring for feature-#34 * enhance test cases * change overlapping port * make refactored classes final * remove unused import from RlpLogbackAppender * add licenses * add locking to ensure configurations are set * update readme * change to use AtomicReference and new immutable decorateable RelpAppender implementations * improve test assertion for threadedTest so that it ensures all messages were sent * update assertion message to proper grammar in RlpLogbackAppenderTest * remove extra curly bracket from Hostname default err message * add parentheses for readability in RlpLogbackAppender maxIdleEnabled * update README.adoc to include defaults * enable rebind as default
- Loading branch information
Showing
19 changed files
with
981 additions
and
565 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
82 changes: 0 additions & 82 deletions
82
src/main/java/com/teragrep/jla_01/LoggingEventConverter.java
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
/* | ||
Reliable Event Logging Protocol (RELP) Logback plugin | ||
Copyright (C) 2021-2024 Suomen Kanuuna Oy | ||
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 com.teragrep.jla_01; | ||
|
||
import com.teragrep.rlp_01.pool.Stubable; | ||
|
||
public interface RelpAppender<E> extends Stubable { | ||
|
||
void append(E iLoggingEvent); | ||
void stop(); | ||
} |
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,73 @@ | ||
/* | ||
Reliable Event Logging Protocol (RELP) Logback plugin | ||
Copyright (C) 2021-2024 Suomen Kanuuna Oy | ||
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 com.teragrep.jla_01; | ||
|
||
import ch.qos.logback.core.encoder.LayoutWrappingEncoder; | ||
import com.teragrep.jla_01.syslog.*; | ||
import com.teragrep.rlp_01.client.IManagedRelpConnection; | ||
import com.teragrep.rlp_01.pool.Pool; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
public final class RelpAppenderImpl<E> implements RelpAppender<E> { | ||
|
||
private final Pool<IManagedRelpConnection> relpConnectionPool; | ||
private final String hostname; | ||
private final String appName; | ||
private final String originalHostname; | ||
private final boolean enableEventId48577; | ||
private final LayoutWrappingEncoder<E> encoder; | ||
|
||
public RelpAppenderImpl(Pool<IManagedRelpConnection> relpConnectionPool, String hostname, String appName, String originalHostname, boolean enableEventId48577, LayoutWrappingEncoder<E> encoder) { | ||
this.relpConnectionPool = relpConnectionPool; | ||
this.hostname = hostname; | ||
this.appName = appName; | ||
this.originalHostname = originalHostname; | ||
this.enableEventId48577 = enableEventId48577; | ||
this.encoder = encoder; | ||
} | ||
|
||
@Override | ||
public void append(E iLoggingEvent) { | ||
{ | ||
SyslogRecord syslogRecord = new SyslogRecordConfigured(hostname, appName); | ||
syslogRecord = new SyslogRecordTimestamp(syslogRecord); | ||
syslogRecord = new SyslogRecordOrigin(syslogRecord, originalHostname); | ||
if (enableEventId48577) { | ||
syslogRecord = new SyslogRecordEventID(syslogRecord, originalHostname); | ||
} | ||
|
||
//syslogRecord = new SyslogRecordMDC(syslogRecord, new HashMap<>()); | ||
|
||
String payload = encoder.getLayout().doLayout(iLoggingEvent); | ||
syslogRecord = new SyslogRecordPayload(syslogRecord, payload); | ||
|
||
IManagedRelpConnection connection = relpConnectionPool.get(); | ||
|
||
connection.ensureSent(syslogRecord.getRecord().toRfc5424SyslogMessage().getBytes(StandardCharsets.UTF_8)); | ||
relpConnectionPool.offer(connection); | ||
} | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
relpConnectionPool.close(); | ||
} | ||
|
||
@Override | ||
public boolean isStub() { | ||
return false; | ||
} | ||
} |
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,32 @@ | ||
/* | ||
Reliable Event Logging Protocol (RELP) Logback plugin | ||
Copyright (C) 2021-2024 Suomen Kanuuna Oy | ||
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 com.teragrep.jla_01; | ||
|
||
public final class RelpAppenderStub<E> implements RelpAppender<E> { | ||
@Override | ||
public void append(E iLoggingEvent) { | ||
throw new UnsupportedOperationException("RelpAppenderStub does not support this. Perhaps appender is not started yet."); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
throw new UnsupportedOperationException("RelpAppenderStub does not support this. Perhaps appender is not started yet."); | ||
} | ||
|
||
@Override | ||
public boolean isStub() { | ||
return true; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/teragrep/jla_01/RelpAppenderSynchronized.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,39 @@ | ||
/* | ||
Reliable Event Logging Protocol (RELP) Logback plugin | ||
Copyright (C) 2021-2024 Suomen Kanuuna Oy | ||
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 com.teragrep.jla_01; | ||
|
||
public final class RelpAppenderSynchronized<E> implements RelpAppender<E> { | ||
|
||
private final RelpAppender<E> appender; | ||
|
||
public RelpAppenderSynchronized(RelpAppender<E> relpAppender) { | ||
this.appender = relpAppender; | ||
} | ||
|
||
@Override | ||
public synchronized void append(E iLoggingEvent) { | ||
appender.append(iLoggingEvent); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
appender.stop(); | ||
} | ||
|
||
@Override | ||
public boolean isStub() { | ||
return false; | ||
} | ||
} |
Oops, something went wrong.