5050import java .nio .ByteBuffer ;
5151import java .nio .ByteOrder ;
5252import java .nio .channels .FileChannel ;
53- import java .nio .channels .FileLock ;
5453import java .nio .channels .ReadableByteChannel ;
5554import java .nio .channels .SeekableByteChannel ;
5655import java .nio .file .FileSystems ;
@@ -275,7 +274,6 @@ public Connection findFirstConnectionByMd5Sum(String msgMd5Sum) {
275274 public void forFirstTopicWithMessagesOfType (String messageType , MessageHandler handler ) throws BagReaderException {
276275 for (Connection conn : myConnectionsByType .get (messageType )) {
277276 try (FileChannel channel = getChannel ()) {
278- FileLock lock = channel .lock (0 , Long .MAX_VALUE , true );
279277 MsgIterator iter = new MsgIterator (myChunkInfos , conn , channel );
280278
281279 while (iter .hasNext ()) {
@@ -307,7 +305,6 @@ public void forFirstTopicWithMessagesOfType(String messageType, MessageHandler h
307305 public void forMessagesOfType (String messageType , MessageHandler handler ) throws BagReaderException {
308306 for (Connection conn : myConnectionsByType .get (messageType )) {
309307 try (FileChannel channel = getChannel ()) {
310- FileLock lock = channel .lock (0 , Long .MAX_VALUE , true );
311308 MsgIterator iter = new MsgIterator (myChunkInfos , conn , channel );
312309
313310 while (iter .hasNext ()) {
@@ -336,7 +333,6 @@ public void forMessagesOfType(String messageType, MessageHandler handler) throws
336333 public void forMessagesOnTopic (String topic , MessageHandler handler ) throws BagReaderException {
337334 for (Connection conn : myConnectionsByTopic .get (topic )) {
338335 try (FileChannel channel = getChannel ()) {
339- FileLock lock = channel .lock (0 , Long .MAX_VALUE , true );
340336 MsgIterator iter = new MsgIterator (myChunkInfos , conn , channel );
341337
342338 while (iter .hasNext ()) {
@@ -361,7 +357,6 @@ public void forMessagesOnTopic(String topic, MessageHandler handler) throws BagR
361357 public MessageType getFirstMessageOfType (String messageType ) throws BagReaderException {
362358 for (Connection conn : myConnectionsByType .get (messageType )) {
363359 try (FileChannel channel = getChannel ()) {
364- FileLock lock = channel .lock (0 , Long .MAX_VALUE , true );
365360 MsgIterator iter = new MsgIterator (myChunkInfos , conn , channel );
366361 if (iter .hasNext ()) {
367362 return iter .next ();
@@ -388,7 +383,6 @@ public MessageType getFirstMessageOfType(String messageType) throws BagReaderExc
388383 public MessageType getFirstMessageOnTopic (String topic ) throws BagReaderException {
389384 for (Connection conn : myConnectionsByTopic .get (topic )) {
390385 try (FileChannel channel = getChannel ()) {
391- FileLock lock = channel .lock (0 , Long .MAX_VALUE , true );
392386 MsgIterator iter = new MsgIterator (myChunkInfos , conn , channel );
393387 if (iter .hasNext ()) {
394388 return iter .next ();
@@ -507,7 +501,6 @@ else if (compression.equals("lz4")) {
507501 chunkPositions .add (info .getChunkPos ());
508502 }
509503 try (FileChannel channel = getChannel ()) {
510- FileLock lock = channel .lock (0 , Long .MAX_VALUE , true );
511504 for (Long chunkPos : chunkPositions ) {
512505 Chunk chunk = new Chunk (recordAt (channel , chunkPos ));
513506 String compression = chunk .getCompression ();
@@ -598,7 +591,6 @@ public MessageType getMessageOnTopicAtIndex(String topic,
598591 }
599592
600593 try (FileChannel channel = getChannel ()) {
601- FileLock lock = channel .lock (0 , Long .MAX_VALUE , true );
602594 MessageIndex msgIndex = indexes .get (index );
603595 Record record = BagFile .recordAt (channel , msgIndex .fileIndex );
604596 ByteBufferChannel chunkChannel = new ByteBufferChannel (record .getData ());
@@ -626,7 +618,6 @@ public MessageType getMessageOnTopicAtIndex(String topic,
626618 private void generateIndexesForTopic (String topic ) throws BagReaderException {
627619 List <MessageIndex > msgIndexes = Lists .newArrayList ();
628620 try (FileChannel channel = getChannel ()) {
629- FileLock lock = channel .lock (0 , Long .MAX_VALUE , true );
630621 for (Connection conn : myConnectionsByTopic .get (topic )) {
631622 for (ChunkInfo chunkInfo : myChunkInfosByConnectionId .get (conn .getConnectionId ())) {
632623 long chunkPos = chunkInfo .getChunkPos ();
@@ -807,7 +798,6 @@ public void read() throws BagReaderException {
807798 }
808799
809800 try (FileChannel input = getChannel ()){
810- FileLock lock = input .lock (0 , Long .MAX_VALUE , true );
811801 verifyBagFile (input );
812802
813803 while (hasNext (input )) {
0 commit comments