-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit makes deserialization of Beats messages lazy for messages sent via the V2 protocol. Instead of deserializing in the parsing block, the ByteBuf is copied to the Batch instance, which will deserialize when the data is needed. Also: Fixes an integration test which was failing regularly on Travis Fixes #299
- Loading branch information
Showing
17 changed files
with
503 additions
and
231 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 |
---|---|---|
|
@@ -181,7 +181,6 @@ def create_server | |
|
||
server.enableSSL(ssl_builder) | ||
end | ||
|
||
server | ||
end | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,48 @@ | ||
package org.logstash.beats; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Batch { | ||
private byte protocol = Protocol.VERSION_2; | ||
private int batchSize; | ||
private List<Message> messages = new ArrayList(); | ||
|
||
public List<Message> getMessages() { | ||
return messages; | ||
} | ||
|
||
public void addMessage(Message message) { | ||
message.setBatch(this); | ||
messages.add(message); | ||
} | ||
|
||
public int size() { | ||
return messages.size(); | ||
} | ||
|
||
public void setBatchSize(int size) { | ||
batchSize = size; | ||
} | ||
|
||
public int getBatchSize() { | ||
return batchSize; | ||
} | ||
|
||
public boolean isEmpty() { | ||
return 0 == messages.size(); | ||
} | ||
|
||
public boolean complete() { | ||
return size() == getBatchSize(); | ||
} | ||
|
||
public byte getProtocol() { | ||
return protocol; | ||
} | ||
|
||
public void setProtocol(byte protocol) { | ||
this.protocol = protocol; | ||
} | ||
} | ||
/** | ||
* Interface representing a Batch of {@link Message}. | ||
*/ | ||
public interface Batch extends Iterable<Message>{ | ||
/** | ||
* Returns the protocol of the sent messages that this batch was constructed from | ||
* @return byte - either '1' or '2' | ||
*/ | ||
byte getProtocol(); | ||
|
||
/** | ||
* Number of messages that the batch is expected to contain. | ||
* @return int - number of messages | ||
*/ | ||
int getBatchSize(); | ||
|
||
/** | ||
* Set the number of messages that the batch is expected to contain. | ||
* @param batchSize int - number of messages | ||
*/ | ||
void setBatchSize(int batchSize); | ||
|
||
/** | ||
* Current number of messages in the batch | ||
* @return int | ||
*/ | ||
int size(); | ||
|
||
/** | ||
* Is the batch currently empty? | ||
* @return boolean | ||
*/ | ||
boolean isEmpty(); | ||
|
||
/** | ||
* Is the batch complete? | ||
* @return boolean | ||
*/ | ||
boolean isComplete(); | ||
|
||
/** | ||
* Release the resources associated with the batch. Consumers of the batch *must* release | ||
* after use. | ||
*/ | ||
void release(); | ||
} |
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.