/// <summary> /// Returns an XMl representation of special objects on the system. /// The only real use-case we can imagine for now is the list of NT VSS providers /// (System state, Exchange and SQLServer providers, maybe HyperV vm images) /// Another use case (not studied yet) would be VMWare®© storage API /// </summary> /*internal static string BuildObjectsList(){ * string xml = ""; * xml += "<objects name=\"/\" type=\"\" version=\"\">"; * ISnapshotProvider provider = SnapshotProvider.GetProvider(); * foreach(ISnapshot sn in provider.ListSpecialObjects()){ * xml += "<object name=\""+sn.Name+"\" path=\""+sn.Path+"\" version=\""+sn.Version+"\" type=\""+sn.Type+"\">"; * foreach(ISnapshot childSn in sn.ChildComponents) * xml += "<childObject name=\""+childSn.Name+"\" path=\""+childSn.Path+"\" version=\""+childSn.Version+"\" type=\""+childSn.Type+"\" leaf=\"true\"/>"; * xml += "</object>"; * } * xml += "</objects>"; * return xml; * }*/ internal static string BuildObjectsList() { string xml = ""; xml += "{name:\"VSS Writers\", type:\"\", version:\"\", children:["; if (!Utilities.PlatForm.IsUnixClient()) { ISnapshotProvider provider = SnapshotProvider.GetProvider("VSS"); List <ISnapshot> spos = provider.ListSpecialObjects(); if (spos != null) { foreach (ISnapshot sn in spos) { xml += "{name:\"" + sn.Path + "\", path:\"" + sn.MountPoint + "\", version:\"" + sn.Version + "\", type:\"" + sn.Type + "\", disabled:\"" + sn.Disabled + "\", checked:false, children:["; foreach (ISnapshot childSn in sn.ChildComponents) { xml += "{name:\"" + childSn.Path + "\", path:\"" + childSn.MountPoint + "\", version:\"" + childSn.Version + "\", type:\"" + childSn.Type + "\", leaf:\"true\", disabled:\"" + childSn.Disabled + "\", icon:\"" + ((childSn.Icon == null)? "" : "data:image/x-windows-bmp;base64," + Convert.ToBase64String(childSn.Icon)) + "\""; if (childSn.Disabled == false) { xml += ", checked:false"; } xml += "},"; } xml += "]},"; } } } xml += "]}"; return(xml); }
public ConsulClientV1(Polymath polymath) { ACL = new ACLProvider(polymath); Agent = new AgentProvider(polymath); Event = new EventProvider(polymath); KeyValue = new KeyValueProvider(polymath); Session = new SessionProvider(polymath); Snapshot = new SnapshotProvider(polymath); Status = new StatusProvider(polymath); Transaction = new TransactionProvider(polymath); }
public void Terminate(bool isSuccessful) { Logger.Append(Severity.DEBUG, "Calling Terminate"); //if( isSuccessful && bs.BackupTimes[0].Type == BackupType.Full) // IncrementalProvider.SignalFullBackup(); // delete snapshots try{ // Execute post-backup commands string[] postCmdOut = ExecuteCommand(this.BackupSet.Postop); HubNotificationEvent(this.Id, 711, "STDOUT", postCmdOut[0]); HubNotificationEvent(this.Id, 711, "STDERR", postCmdOut[1]); Logger.Append(Severity.DEBUG, "Disposing storage layout builders..."); if (slManager != null) { slManager.Dispose(); } foreach (ISnapshotProvider prov in snapshotProviders) { if (prov != null) { prov.Dispose(); } } snapshotProviders = null; } catch (Exception e) { Logger.Append(Severity.ERROR, "Error cleaning task resources : " + e.ToString()); } if (this.BackupSet.SnapshotRetention == 0) { foreach (BackupRootDrive rootDrive in this.backupRootDrives) { try{ //string prov = SnapshotProvider.GetDriveSnapshotProviderName(rootDrive.SystemDrive.MountPoint); SnapshotProvider.GetProvider(rootDrive.Snapshot.Type).Delete(rootDrive.Snapshot); //SnapshotProvider.GetProvider(prov) } catch (Exception e) { AddHubNotificationEvent(906, rootDrive.Snapshot.Path, e.Message); } } } Logger.Append(Severity.DEBUG, "Terminated"); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void baseNoSendTest(java.util.Map<org.neo4j.cluster.InstanceId,java.net.URI> extraMembers) throws Throwable private void BaseNoSendTest(IDictionary <InstanceId, URI> extraMembers) { URI me = URI.create("cluster://me"); IDictionary <InstanceId, URI> members = new Dictionary <InstanceId, URI>(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.InstanceId myId = new org.neo4j.cluster.InstanceId(1); InstanceId myId = new InstanceId(1); members[myId] = me; //JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method: members.putAll(extraMembers); ClusterConfiguration clusterConfiguration = mock(typeof(ClusterConfiguration)); when(clusterConfiguration.Members).thenReturn(members); when(clusterConfiguration.GetElected(ClusterConfiguration.COORDINATOR)).thenReturn(myId); when(clusterConfiguration.GetUriForId(myId)).thenReturn(me); ClusterContext clusterContext = mock(typeof(ClusterContext)); when(clusterContext.Configuration).thenReturn(clusterConfiguration); when(clusterContext.MyId).thenReturn(myId); SnapshotContext context = mock(typeof(SnapshotContext)); when(context.ClusterContext).thenReturn(clusterContext); SnapshotProvider snapshotProvider = mock(typeof(SnapshotProvider)); when(context.SnapshotProvider).thenReturn(snapshotProvider); Message <SnapshotMessage> message = Message.to(SnapshotMessage.RefreshSnapshot, me); MessageHolder outgoing = mock(typeof(MessageHolder)); SnapshotState newState = ( SnapshotState )SnapshotState.Ready.handle(context, message, outgoing); assertThat(newState, equalTo(SnapshotState.Ready)); Mockito.verifyZeroInteractions(outgoing); }
private void TakeRequiredSnapshots() { try { if (SnapshotProvider != null) { if (SnapshotProvider.EndOfDay.Date == DateTime.Today) // don't take snapshots on a non-trading day { var snapshotRows = GetStartOfTradingSnapshotsDue(); foreach (var row in snapshotRows) { row.StartOfTradingSnapshotTaken = 1; SnapshotProvider.TakeSnapshot(row.AcctName, "StartOfTrading"); } snapshotRows = GetEndOfTradingSnapshotsDue(); foreach (var row in snapshotRows) { row.EndOfTradingSnapshotTaken = 1; SnapshotProvider.TakeSnapshot(row.AcctName, "EndOfTrading"); } if (DateTime.Now > SnapshotProvider.EndOfDay) { snapshotRows = GetEndOfDaySnapshotsDue(); foreach (var row in snapshotRows) { row.EndOfDaySnapshotTaken = 1; SnapshotProvider.TakeSnapshot(row.AcctName, "EndOfDay"); } } } } } catch (Exception ex) { Error("Exception in TakeRequiredSnapshots method", ex); } }
/// <summary> /// Esto es para evitar que al hacer un update que no coincide funcione /// </summary> private void RegisterSnapshoter(IUnityContainer container) { var snapshoter = new SnapshotProvider("Snapshoter", container.Resolve <ISystemTime>(), container.Resolve <Func <EventStoreDbContext> >(), container.Resolve <ITextSerializer>(), this.Tracer); container.RegisterInstance <ISnapshotProvider>(snapshoter); }
/// <summary> /// This method first looks if backup needs snapshotting drives. If so, then we do snapshot /// and use it to call BuildBackup method /// </summary> private void PrepareDrivesAndSnapshots() { SnapshotSupportedLevel snapLevel = ConvertBackupLevelToSnLevel(this.Level); Logger.Append(Severity.INFO, "Preparing backup for Task " + this.Id); HubNotificationEvent(this.Id, 701 /*snapshotting*/, "", ""); backupRootDrives = GetBackupInvolvedRootDrives(); Console.WriteLine("PrepareDrivesAndSnapshots()() backupRootDrives count=" + backupRootDrives.Count); string[] snapshotProvNames = new string[backupRootDrives.Count]; for (int i = 0; i < backupRootDrives.Count; i++) { if (backupRootDrives[i].RequiresSnapshot) { snapshotProvNames[i] = SnapshotProvider.GetDriveSnapshotProviderName(backupRootDrives[i].SystemDrive.MountPoint); } else { snapshotProvNames[i] = "NONE"; } } // the final list of all snapshot needed to perform the backup set backupSnapshots = new List <ISnapshot>(); // We try to make all snapshot in the shortest amount of time we can, // for data to be as consistent as possible foreach (string snapProv in snapshotProvNames.Distinct()) { Console.WriteLine("PrepareDrivesAndSnapshots() snapshotProvNames=" + snapProv); List <FileSystem> snapShotMemberDrives = new List <FileSystem>(); for (int i = 0; i < backupRootDrives.Count; i++) { if (snapshotProvNames[i] == snapProv) { snapShotMemberDrives.Add(backupRootDrives[i].SystemDrive); } } //Gather SpecialObjects (VSS writers) if any var spoList = from BasePath bp in this.BackupSet.BasePaths where bp.Type != null && bp.Type.ToLower().StartsWith("object:") //P2PBackup.Common.BasePath.PathType.OBJECT select bp.Path; ISnapshotProvider snapProvider = SnapshotProvider.GetProvider(snapProv); snapshotProviders.Add(snapProvider); snapProvider.LogEvent += LogReceivedEvent; ISnapshot[] volSnaps; try{ volSnaps = snapProvider.CreateVolumeSnapShot(snapShotMemberDrives, spoList.ToArray(), snapLevel); //if(snapProvider.Metadata != null) // Index.Header.ProviderMetadata.Add(new Tuple<string, Hashtable>(snapProvider.Name, snapProvider.Metadata.Metadata)); string volList = ""; foreach (FileSystem vol in snapShotMemberDrives) { volList += vol.MountPoint + ","; } Logger.Append(Severity.INFO, "Took snapshots (type " + snapProvider.Type + ") of drives " + volList); } catch (Exception e) { // we return a fake snapshot (snapshot path is the volume itself) string volList = ""; foreach (FileSystem vol in snapShotMemberDrives) { volList += vol.MountPoint + ","; } Logger.Append(Severity.WARNING, "Unable to take snapshot of drives " + volList + ", falling back to fake provider. Error was : " + e.Message + " --- " + e.StackTrace); HubNotificationEvent(this.Id, 805 /*cant snapshot*/, volList, e.Message); ISnapshotProvider nullProv = SnapshotProvider.GetProvider("NONE"); volSnaps = nullProv.CreateVolumeSnapShot(snapShotMemberDrives, spoList.ToArray(), snapLevel); } backupSnapshots.AddRange(volSnaps); snapProvider.LogEvent -= LogReceivedEvent; } //finally, add snapshot to corresponding BackupRootDrive Console.WriteLine("##### dumping rootdrives : "); foreach (BackupRootDrive rd in backupRootDrives) { foreach (ISnapshot snap in backupSnapshots) { if (/*snap.MountPoint*/ snap.Path == rd.SystemDrive.MountPoint) { rd.Snapshot = snap; Console.WriteLine("matched snapshot : " + snap.Path + ", snap mount path=" + snap.MountPoint); // let's change paths and excluded paths to their snapshotted values foreach (BasePath bp in rd.Paths) { //bp.Path = snap.Path + bp.Path; /*if(snap.Name == "/") * bp.Path = snap.Path; * else * bp.Path = bp.Path.Replace(snap.Name, snap.Path);*/ for (int i = 0; i < bp.ExcludedPaths.Count; i++) { //bp.ExcludedPaths[i] = snap.Path + bp.ExcludedPaths[i]; if (snap.Path == "/") { bp.ExcludedPaths[i] = snap.MountPoint + bp.ExcludedPaths[i]; } else { bp.ExcludedPaths[i] = bp.ExcludedPaths[i].Replace(snap.Path, snap.MountPoint); //bp.ExcludedPaths[i] = bp.ExcludedPaths[i].Replace(snap.Name, ""); //bp.ExcludedPaths[i] = Path.Combine(snap.Path, bp.ExcludedPaths[i]); //bp.ExcludedPaths[i] = Path.GetFullPath(bp.ExcludedPaths[i]); } } } break; } } Console.WriteLine("BackupRootDrive id=" + rd.ID + ", mount=" + rd.SystemDrive.MountPoint /*+", snapshot= "+rd.snapshot.Path*/); foreach (BasePath p in rd.Paths) { Console.WriteLine("\t p=" + p.Path + ", excludes : "); foreach (string s in p.ExcludedPaths) { Console.WriteLine("\t excluded " + s); } Console.WriteLine("\t\t, include patterns : "); foreach (string s in p.IncludePolicy) { Console.WriteLine("\t match " + s); } } } Console.WriteLine("##### #####"); foreach (BackupRootDrive rds in backupRootDrives) { Logger.Append(Severity.DEBUG, "Drive '" + rds.SystemDrive.OriginalMountPoint + "' was snapshotted to '" + rds.Snapshot.MountPoint + "' using provider '" + rds.Snapshot.Type + "' with timestamp " + rds.Snapshot.TimeStamp + " (" + Utils.GetLocalDateTimeFromUnixTime(rds.Snapshot.TimeStamp) + ")"); } }