Esempio n. 1
0
        public void SetLease(LeaseToken leaseToken)
        {
            LeaseToken token = new LeaseToken(leaseToken.Path, leaseToken.Expiry, leaseToken.Type, leaseToken.LastSync, leaseToken.Expiry + this.interSiteLeaseExpiryInterval + FileLeaseManager.LeaseExpiryCriticalAlertPadding, leaseToken.Version);

            FileLeaseManager.LeaseOperationResult leaseOperationResult = FileLeaseManager.TryRunLeaseOperation(new FileLeaseManager.LeaseOperation(this.SetLeaseOperation), new FileLeaseManager.LeaseOperationRequest(token));
            if (!leaseOperationResult.Succeeded)
            {
                this.logSession.LogException(EdgeSyncLoggingLevel.Low, EdgeSyncEvent.TargetConnection, leaseOperationResult.Exception, "Sync failed because Edgesync failed to update lease file");
                throw new ExDirectoryException(leaseOperationResult.Exception);
            }
        }
Esempio n. 2
0
 public LeaseToken GetLease()
 {
     FileLeaseManager.LeaseOperationResult leaseOperationResult = FileLeaseManager.TryRunLeaseOperation(new FileLeaseManager.LeaseOperation(FileLeaseManager.GetLeaseOperation), new FileLeaseManager.LeaseOperationRequest(this.primaryLeaseFilePath));
     if (leaseOperationResult.Succeeded)
     {
         if (this.useBackupLeaseLocation)
         {
             this.logSession.LogEvent(EdgeSyncLoggingLevel.Low, EdgeSyncEvent.TargetConnection, null, "Switch back to primary lease from backup lease");
         }
         this.useBackupLeaseLocation = false;
         return(leaseOperationResult.ResultToken);
     }
     this.logSession.LogException(EdgeSyncLoggingLevel.Low, EdgeSyncEvent.TargetConnection, leaseOperationResult.Exception, "Failed to open primary lease file. Switch to backup lease file");
     leaseOperationResult = FileLeaseManager.TryRunLeaseOperation(new FileLeaseManager.LeaseOperation(FileLeaseManager.GetLeaseOperation), new FileLeaseManager.LeaseOperationRequest(this.backupLeaseFilePath));
     if (leaseOperationResult.Succeeded)
     {
         this.logSession.LogEvent(EdgeSyncLoggingLevel.Low, EdgeSyncEvent.TargetConnection, null, "Successfully failed over to backup lease file");
         this.useBackupLeaseLocation = true;
         return(leaseOperationResult.ResultToken);
     }
     this.logSession.LogException(EdgeSyncLoggingLevel.Low, EdgeSyncEvent.TargetConnection, leaseOperationResult.Exception, "Failed to open backup lease file");
     throw new ExDirectoryException(leaseOperationResult.Exception);
 }