forked from jitsi/jitsi-utils
-
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.
ref: Moves the packet queue classes in their own package.
- Loading branch information
Showing
8 changed files
with
135 additions
and
89 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
83 changes: 83 additions & 0 deletions
83
src/main/java/org/jitsi/utils/queue/CountingErrorHandler.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,83 @@ | ||
/* | ||
* Copyright @ 2019 - present 8x8, Inc. | ||
* | ||
* 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 org.jitsi.utils.queue; | ||
|
||
import org.jitsi.utils.logging.*; | ||
|
||
import java.util.concurrent.atomic.*; | ||
|
||
/** | ||
* An {@link ErrorHandler} implementation which counts the number of | ||
* dropped packets and exceptions. | ||
* | ||
* @author Boris Grozev | ||
*/ | ||
public class CountingErrorHandler implements ErrorHandler | ||
{ | ||
/** | ||
* The {@link Logger} used by the {@link PacketQueue} class and its | ||
* instances for logging output. | ||
*/ | ||
private static final Logger logger | ||
= Logger.getLogger(PacketQueue.class.getName()); | ||
|
||
/** | ||
* The number of dropped packets. | ||
*/ | ||
private final AtomicLong numPacketsDropped = new AtomicLong(); | ||
|
||
/** | ||
* The number of exceptions. | ||
*/ | ||
private final AtomicLong numExceptions = new AtomicLong(); | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void packetDropped() | ||
{ | ||
numPacketsDropped.incrementAndGet(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void packetHandlingFailed(Throwable t) | ||
{ | ||
logger.warn("Failed to handle packet: ", t); | ||
numExceptions.incrementAndGet(); | ||
} | ||
|
||
/** | ||
* Get the number of dropped packets. | ||
* @return | ||
*/ | ||
public long getNumPacketsDropped() | ||
{ | ||
return numPacketsDropped.get(); | ||
} | ||
|
||
/** | ||
* Get the number of exceptions. | ||
* @return | ||
*/ | ||
public long getNumExceptions() | ||
{ | ||
return numExceptions.get(); | ||
} | ||
} |
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 @ 2019 - present 8x8, Inc. | ||
* | ||
* 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 org.jitsi.utils.queue; | ||
|
||
/** | ||
* An interface for handling the two types of error conditions from a queue. | ||
* | ||
* @author Boris Grozev | ||
*/ | ||
public interface ErrorHandler | ||
{ | ||
/** | ||
* Called when a packet is dropped from the queue because a new packet | ||
* was added while it was full. | ||
*/ | ||
default void packetDropped() {} | ||
|
||
/** | ||
* Called when handling of a packet produces an exception. | ||
* @param t | ||
*/ | ||
default void packetHandlingFailed(Throwable t) {} | ||
} |
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