Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Counts raft replication events. More precisely counts:
new replication, nbr of attempts, successful and failed. Also logs number of attempts if more than 1
- Loading branch information
Showing
7 changed files
with
310 additions
and
64 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
75 changes: 75 additions & 0 deletions
75
...ava/org/neo4j/causalclustering/core/replication/monitoring/LoggingReplicationMonitor.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,75 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j Enterprise Edition. The included source | ||
* code can be redistributed and/or modified under the terms of the | ||
* GNU AFFERO GENERAL PUBLIC LICENSE Version 3 | ||
* (http://www.fsf.org/licensing/licenses/agpl-3.0.html) with the | ||
* Commons Clause, as found in the associated LICENSE.txt file. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* Neo4j object code can be licensed independently from the source | ||
* under separate terms from the AGPL. Inquiries can be directed to: | ||
* licensing@neo4j.com | ||
* | ||
* More information is also available at: | ||
* https://neo4j.com/licensing/ | ||
*/ | ||
package org.neo4j.causalclustering.core.replication.monitoring; | ||
|
||
import org.neo4j.causalclustering.core.replication.ReplicatedContent; | ||
import org.neo4j.logging.Log; | ||
|
||
import static java.lang.String.format; | ||
|
||
public class LoggingReplicationMonitor implements ReplicationMonitor | ||
{ | ||
private final Log log; | ||
private int attempts; | ||
private ReplicatedContent current; | ||
|
||
public LoggingReplicationMonitor( Log log ) | ||
{ | ||
this.log = log; | ||
} | ||
|
||
@Override | ||
public void startReplication( ReplicatedContent command ) | ||
{ | ||
clear( command ); | ||
} | ||
|
||
@Override | ||
public void replicationAttempt() | ||
{ | ||
if ( attempts > 0 ) | ||
{ | ||
log.warn( format( "Failed to replicated content. Attempt %d, Content: %s", attempts, current ) ); | ||
} | ||
attempts++; | ||
} | ||
|
||
@Override | ||
public void successfulReplication() | ||
{ | ||
clear( null ); | ||
} | ||
|
||
@Override | ||
public void failedReplication( Throwable t ) | ||
{ | ||
clear( null ); | ||
log.error( "Failed to replicated content", t ); | ||
} | ||
|
||
private void clear( ReplicatedContent o ) | ||
{ | ||
current = o; | ||
attempts = 0; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../main/java/org/neo4j/causalclustering/core/replication/monitoring/ReplicationMonitor.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,36 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j Enterprise Edition. The included source | ||
* code can be redistributed and/or modified under the terms of the | ||
* GNU AFFERO GENERAL PUBLIC LICENSE Version 3 | ||
* (http://www.fsf.org/licensing/licenses/agpl-3.0.html) with the | ||
* Commons Clause, as found in the associated LICENSE.txt file. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* Neo4j object code can be licensed independently from the source | ||
* under separate terms from the AGPL. Inquiries can be directed to: | ||
* licensing@neo4j.com | ||
* | ||
* More information is also available at: | ||
* https://neo4j.com/licensing/ | ||
*/ | ||
package org.neo4j.causalclustering.core.replication.monitoring; | ||
|
||
import org.neo4j.causalclustering.core.replication.ReplicatedContent; | ||
|
||
public interface ReplicationMonitor | ||
{ | ||
void startReplication( ReplicatedContent command ); | ||
|
||
void replicationAttempt(); | ||
|
||
void successfulReplication(); | ||
|
||
void failedReplication( Throwable t ); | ||
} |
Oops, something went wrong.