Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2009 eXo Platform SAS.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.exoplatform.services.jcr.ext.replication.recovery;
 
 
 import java.io.File;
 import java.util.List;

Created by The eXo Platform SAS.

Author(s):
Alex Reshetnyak
Version:
$Id: RecoveryManager.java 34445 2009-07-24 07:51:18Z dkatayev $
 
 
 public class RecoveryManager
 {

   
The apache logger.
 
    private static Log log = ExoLogger.getLogger("exo.jcr.component.ext.RecoveryManager");

   
The FileNameFactory will be created file names.
 
    private FileNameFactory fileNameFactory;

   
The RecoveryWriter will be wrote the ChangesLog to file system.
 
    private RecoveryWriter recoveryWriter;

   
The RecoveryReader will be read the ChangesLog on file system.
 
    private RecoveryReader recoveryReader;

   
The date to ChangesLog.
 
    private Calendar timeStamp;

   
The name of cluster node.
 
    private String ownName;

   
The repository name.
 
    private String repoName;

   
The workspace name.
 
    private String wsName;

   
The timeout to wait confirmation.
 
    private long waitConfirmationTimeout;

   
The HashMap with PendingConfirmationChengesLog.
The RecoverySynchronizer will be initialized the recovery.
The ChannelManager will be transmitted or receive the Packets.
   private ChannelManager channelManager;

   
The list of names other participants.
   private List<StringparticipantsClusterList;

   
The list of names other participants who was initialized.
The boolean flag to all members was initialized.
   private boolean isAllInited;

   
RecoveryManager constructor.

Parameters:
recoveryDir the recovery dir
ownName the own name
systemId the system identification string
participantsClusterList the other participants
waitConformation the timeout to confirmation
repoName the repository name
wsName the workspace name
channelManager the ReplicationChannelManager
fileCleaner the file cleaner
maxBufferSize int, the max buffer size
holder ReaderSpoolFileHolder, the reader spool file holder
Throws:
java.io.IOException will be generated the IOException
   public RecoveryManager(File recoveryDirString ownNameString systemIdList<StringparticipantsClusterList,
      long waitConformationString repoNameString wsNameReplicationChannelManager channelManager,
      FileCleaner fileCleanerint maxBufferSizeReaderSpoolFileHolder holderthrows IOException
   {
      this. = ownName;
      this. = new ArrayList<String>(participantsClusterList);
      .info("init : other participants = " + participantsClusterList.size());
      this. = repoName;
      this. = wsName;
      this. = channelManager;
       = new FileNameFactory();
       = new RecoveryReader(fileCleanerrecoveryDirmaxBufferSizeholder);
       = new RecoveryWriter(recoveryDirfileCleanerownName);
      this. = waitConformation;
         new RecoverySynchronizer(recoveryDirfileCleanerchannelManagerownName,
            systemId);
       = false;
   }

   
save.

Parameters:
cangesLog the ChangesLog with data
identifier the identifier to ChangesLog
Returns:
String return the name of file
Throws:
java.io.IOException will be generated the IOException
   public String save(ItemStateChangesLog cangesLogString identifierthrows IOException
   {
       = Calendar.getInstance();
      PendingConfirmationChengesLog confirmationChengesLog =
         new PendingConfirmationChengesLog(cangesLogidentifier);
      .put(identifierconfirmationChengesLog);
      String fName = this.saveCLog(identifier);
      WaitConfirmation waitConfirmationThread = new WaitConfirmation(thisidentifier);
      waitConfirmationThread.start();
      return fName;
   }

   
confirmationChengesLogSave.

Parameters:
packet the Packet with confirmation
   public void confirmationChengesLogSave(Packet packet)
   {
      PendingConfirmationChengesLog confirmationChengesLog = .get(packet.getIdentifier());
      if (confirmationChengesLog != null)
      {
         if (confirmationChengesLog.getConfirmationList().contains(packet.getOwnerName()) != true)
         {
            if (.isDebugEnabled())
            {
               .debug( + ": Confirmation ChangesLog form : " + packet.getOwnerName());
               .debug("Beefor: Confirmation list size : " + confirmationChengesLog.getConfirmationList().size());
            }
            confirmationChengesLog.getConfirmationList().add(packet.getOwnerName());
            if (.isDebugEnabled())
               .debug("After: Confirmation list size : " + confirmationChengesLog.getConfirmationList().size());
         }
      }
      else
      {
         try
         {
            .removeChangesLog(packet.getIdentifier(), packet.getOwnerName());
         }
         catch (IOException e)
         {
            .error("Can't remove : "e);
         }
      }
   }

   
removeChangesLog.

Parameters:
identifier the identifier to ChangesLog
ownerName the member name
Throws:
java.io.IOException will be generated the IOException
   public void removeChangesLog(String identifierString ownerNamethrows IOException
   {
      .removeChangesLog(identifierownerName);
   }

   
save.

Parameters:
identifier the identifier of ChangesLog
Returns:
String return the name of file
Throws:
java.io.IOException will be generated the IOException
   public String save(String identifierthrows IOException
   {
      PendingConfirmationChengesLog confirmationChengesLog = .get(identifier);
      String fileName = .saveDataInfo(confirmationChengesLog);
      return fileName;
   }

   
saveCLog.

Parameters:
identifier the identifier of ChangesLog
Returns:
String return the name of file
Throws:
java.io.IOException will be generated the IOException
   private String saveCLog(String identifierthrows IOException
   {
      PendingConfirmationChengesLog confirmationChengesLog = .get(identifier);
      String fileName =
         .saveDataFile(confirmationChengesLog.getTimeStamp(), confirmationChengesLog.getIdentifier(),
            (TransactionChangesLog)confirmationChengesLog.getChangesLog());
      confirmationChengesLog.setDataFilePath(fileName);
      return fileName;
   }

   
removeDataFile.

Parameters:
f File, the file
   public void removeDataFile(File f)
   {
   }

   
saveRemovableChangesLog.

Parameters:
fileName the name of file
Throws:
java.io.IOException will be generated the IOException
   public void saveRemovableChangesLog(String fileNamethrows IOException
   {
   }

   
remove.

Parameters:
identifier the identifier to ChangesLog
   public void remove(String identifier)
   {
      .remove(identifier);
   }

   
getPendingConfirmationChengesLogById.

Parameters:
identifier the identifier to ChangesLog
Returns:
PendingConfirmationChengesLog return the PendingConfirmationChengesLog
Throws:
java.lang.Exception will be generated the Exception
   {
      if (.containsKey(identifier) == true)
         return .get(identifier);
      throw new Exception("Can't find the PendingConfirmationChengesLog by identifier : " + identifier);
   }

   
processing.

Parameters:
packet the Packet with data
stat before state
Returns:
int after state
Throws:
java.lang.Exception will be generated the Exception
   public int processing(Packet packetint statthrows Exception
   {
      int state = stat;
      switch (packet.getPacketType())
      {
         case .. :
            if (.equals(packet.getOwnerName()) == false)
            {
               confirmationChengesLogSave(packet);
               if (.isDebugEnabled())
                  .debug( + " : ADD_OK : " + packet.getOwnerName());
            }
            break;
            if (.equals(packet.getOwnerName()) == false)
               .processingPacket(packetstate);
            break;
         case .. :
            if (.equals(packet.getOwnerName()) == true)
               .processingPacket(packetstate);
            break;
            if (.equals(packet.getOwnerName()) == true)
               .processingPacket(packetstate);
            break;
         case .. :
            if (.equals(packet.getOwnerName()) == false)
               .processingPacket(packetstate);
            break;
         case .. :
            if (.equals(packet.getOwnerName()) == false)
               state = .processingPacket(packetstate);
            break;
         case .. :
            if (.equals(packet.getOwnerName()) == false)
            {
               if (.contains(packet.getOwnerName()) == false)
               {
                  .add(packet.getOwnerName());
                  Packet initedPacket =
                     new Packet(.., IdGenerator.generate(), );
                  .sendPacket(initedPacket);
               }
               if (.size() == .size())
               {
                  Packet allInitedPacket = new Packet(.., IdGenerator.generate(), );
                  .sendPacket(allInitedPacket);
               }
            }
            break;
         case .. :
            if (.equals(packet.getOwnerName()) == true && !)
               if (state != .)
               {
                  stat = .;
                  if (.isDebugEnabled())
                     .debug("ALL_INITED : start recovery");
                   = true;
               }
            break;
         case .. :
            if (.equals(packet.getOwnerName()) == false)
            {
               .processingPacket(packetstate);
            }
            break;
            if (.equals(packet.getOwnerName()) == false)
            {
               .processingPacket(packetstate);
            }
            break;
         case .. :
            if (.equals(packet.getOwnerName()) == false)
               if (.contains(packet.getOwnerName()))
               {
                   = false;
                  .remove(packet.getOwnerName());
               }
            break;
         default :
            break;
      }
      return state;
   }

   
setDataKeeper.

Parameters:
dataKeeper the ItemDataKeeper
   public void setDataKeeper(ItemDataKeeper dataKeeper)
   {
      .setDataKeeper(dataKeeper);
   }

   
getParticipantsClusterList.

Returns:
List return the other participants
   {
      return ;
   }

   
isAllInited.

Returns:
boolean return the all initialized flag
   public boolean isAllInited()
   {
      return ;
   }

   
getInitedParticipantsClusterList.

Returns:
List return list of initialized participants
   {
   }

   
getOwnName.

Returns:
String return own name
   public String getOwnName()
   {
      return ;
   }

   
getWorkspaceName.

Returns:
String return the workspace name
   public String getWorkspaceName()
   {
      return ;
   }

   
getRepositoryName.

Returns:
String return the repository name
   public String getRepositoryName()
   {
      return ;
   }

   
getChannelManager.

Returns:
ChannelManager return the channel manager
   {
      return ;
   }

   
Will be initialized the recovery.
   public void startRecovery()
   {
      if (.isDebugEnabled())
         .debug("RecoveryManager.startRecovery() : " +  + "@" + );
   }

   
getRecoveryWriter.

Returns:
RecoveryWriter return the RecoveryWriter
   {
      return ;
   }

   
getRecoveryReader.

Returns:
RecoveryReader return the RecoveryReader
   {
      return ;
   }
New to GrepCode? Check out our FAQ X