*/
private synchronized void handleReplicationSynchronization(ReplicationSyncFileMessage msg) throws Exception
{
Long id = Long.valueOf(msg.getId());
byte[] data = msg.getData();
SequentialFile channel1;
switch (msg.getFileType())
{
case LARGE_MESSAGE:
{
ReplicatedLargeMessage largeMessage = lookupLargeMessage(id, false);
if (!(largeMessage instanceof LargeServerMessageInSync))
{
HornetQServerLogger.LOGGER.largeMessageIncompatible();
return;
}
LargeServerMessageInSync largeMessageInSync=(LargeServerMessageInSync)largeMessage;
channel1 = largeMessageInSync.getSyncFile();
break;
}
case PAGE:
{
Page page = getPage(msg.getPageStore(), (int)msg.getId());
channel1 = page.getFile();
break;
}
case JOURNAL:
{
JournalSyncFile journalSyncFile = filesReservedForSync.get(msg.getJournalContent()).get(id);
FileChannel channel2 = journalSyncFile.getChannel();
if (data == null)
{
channel2.close();
return;
}
channel2.write(ByteBuffer.wrap(data));
return;
}
default:
throw HornetQMessageBundle.BUNDLE.replicationUnhandledFileType(msg.getFileType());
}
if (data == null)
{
channel1.close();
return;
}
if (!channel1.isOpen())
{
channel1.open(1, false);
}
channel1.writeDirect(ByteBuffer.wrap(data), true);
}