Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.backup.impl.BackupOutcome runBackup(org.neo4j.helpers.Args args) throws ToolFailureException
        private BackupOutcome RunBackup(Args args)
        {
            string           host = args.Get(HOST).Trim();
            int              port = args.GetNumber(PORT, BackupServer.DEFAULT_PORT).intValue();
            Path             to   = Paths.get(args.Get(TO).Trim());
            Config           tuningConfiguration = ReadConfiguration(args);
            bool             forensics           = args.GetBoolean(FORENSICS, false, true).Value;
            ConsistencyCheck consistencyCheck    = ParseConsistencyChecker(args);

            if (host.Contains(":"))
            {
                if (!host.StartsWith("[", StringComparison.Ordinal))
                {
                    host = "[" + host;
                }
                if (!host.EndsWith("]", StringComparison.Ordinal))
                {
                    host += "]";
                }
            }

            long timeout = args.GetDuration(TIMEOUT, BackupClient.BIG_READ_TIMEOUT);

            URI backupURI = NewURI(DEFAULT_SCHEME + "://" + host + ":" + port);                 // a bit of validation

            HostnamePort hostnamePort = NewHostnamePort(backupURI);

            return(ExecuteBackup(hostnamePort, to, consistencyCheck, tuningConfiguration, timeout, forensics));
        }
Beispiel #2
0
        private static ConsistencyCheck ParseConsistencyChecker(Args args)
        {
            bool verify = args.GetBoolean(VERIFY, true, true).Value;

            if (verify)
            {
                string consistencyCheckerName = args.Get(CONSISTENCY_CHECKER, ConsistencyCheck.FULL.name(), ConsistencyCheck.FULL.name());
                return(ConsistencyCheck.fromString(consistencyCheckerName));
            }
            return(ConsistencyCheck.NONE);
        }
        /// <summary>
        /// Mezők validálása
        /// </summary>
        /// <param name="columnName"></param>
        /// <returns></returns>
        private string OnValidate(string columnName)
        {
            #region Name
            if (columnName == PropertyPlus.GetPropertyName(() => Name))
            {
                object obj = typeof(CanTxMessageItem).GetProperty(PropertyPlus.GetPropertyName(() => Name)).GetValue(this, null);
                if (!string.IsNullOrWhiteSpace(obj as string))
                {
                    /*Ez itt kell*/
                    _lastError = ConsistencyCheck.Symbol(obj as string);
                    return(_lastError);
                }
                else
                {
                    return(null);
                }
            }
            #endregion

            #region Data
            if (columnName == PropertyPlus.GetPropertyName(() => Data))
            {
                object obj = typeof(CanTxMessageItem).GetProperty(PropertyPlus.GetPropertyName(() => Data)).GetValue(this, null);
                if (string.IsNullOrWhiteSpace(obj as string))
                {
                    /*Ennek itt nincs értelme*/
                    //try { new DataFrameConverter().ConvertFrom(obj as string); }
                    //catch (Exception ex) { LastError = ex.Message; return LastError; }
                }

                return(null);
            }
            else if (columnName == PropertyPlus.GetPropertyName(() => Length))
            {
                object obj = typeof(CanTxMessageItem).GetProperty(PropertyPlus.GetPropertyName(() => Length)).GetValue(this, null);

                if ((int)obj > 8)
                {
                    _lastError = CultureService.Instance.GetString(CultureText.text_DataTooLong);
                    return(_lastError);
                }
            }
            else if (columnName == PropertyPlus.GetPropertyName(() => ArbitrationId))
            {
            }

            _lastError = null;
            return(null);


            #endregion
        }
        public void _0002_FileName()
        {
            Assert.IsNull(ConsistencyCheck.FileName("FileName"));
            Assert.IsNull(ConsistencyCheck.FileName("File Name"));
            Assert.IsNull(ConsistencyCheck.FileName("0123456789012345678901234567890"));
            Assert.IsNull(ConsistencyCheck.FileName("UNICODE_Á_MESSAGE"));

            string msg;

            CultureService.Instance.CurrentCultureName = "hu-HU";
            Assert.IsNotEmpty(msg = ConsistencyCheck.FileName("UNICODE_<_MESSAGE"));
            Assert.AreEqual("A fájlnév nem megnengdett karakter(eket) tartalmaz: '<'", msg); Console.WriteLine(msg);

            Assert.IsNotEmpty(ConsistencyCheck.FileName("UNICODE < MESSAGE"));
        }
Beispiel #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.backup.impl.BackupOutcome runBackupWithLegacyArgs(org.neo4j.helpers.Args args) throws ToolFailureException
        private BackupOutcome RunBackupWithLegacyArgs(Args args)
        {
            string           from = args.Get(FROM).Trim();
            Path             to   = Paths.get(args.Get(TO).Trim());
            Config           tuningConfiguration = ReadConfiguration(args);
            bool             forensics           = args.GetBoolean(FORENSICS, false, true).Value;
            ConsistencyCheck consistencyCheck    = ParseConsistencyChecker(args);

            long timeout = args.GetDuration(TIMEOUT, BackupClient.BIG_READ_TIMEOUT);

            URI backupURI = ResolveBackupUri(from, args, tuningConfiguration);

            HostnamePort hostnamePort = NewHostnamePort(backupURI);

            return(ExecuteBackup(hostnamePort, to, consistencyCheck, tuningConfiguration, timeout, forensics));
        }
Beispiel #6
0
        public override Fallible <BackupStageOutcome> PerformFullBackup(DatabaseLayout targetDatabaseLayout, Config config, OptionalHostnamePort userProvidedAddress)
        {
            HostnamePort fromAddress = _addressResolver.resolveCorrectHAAddress(config, userProvidedAddress);

            _log.info("Resolved address for backup protocol is " + fromAddress);
            ConsistencyCheck consistencyCheck = ConsistencyCheck.NONE;
            bool             forensics        = false;

            try
            {
                string host = fromAddress.Host;
                int    port = fromAddress.Port;
                _backupProtocolService.doFullBackup(host, port, targetDatabaseLayout, consistencyCheck, config, _timeout, forensics);
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Success, null));
            }
            catch (ComException e)
            {
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.WrongProtocol, e));
            }
        }
        private void buttonOk_Click(object sender, EventArgs e)
        {
            var fullPath = string.Empty;

            try
            {
                fullPath = PathService.Instance.CreateNewProjectPath(textBoxLocation.Text, textBoxProductName.Text, textBoxName.Text, checkBoxSubdirectory.Checked);
                string result = null;

                if ((result = ConsistencyCheck.FileName(textBoxName.Text)) != null)
                {
                    throw new ArgumentException(result, @"File Name");
                }

                if (Directory.Exists(Path.GetDirectoryName(fullPath)) == false)
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
                }

                if (Directory.Exists(Path.GetDirectoryName(fullPath)) == false)
                {
                    MessageBox.Show(CultureService.Instance.GetString(CultureText.text_DirectoryCannotBeCreated) + "\n" + Path.GetDirectoryName(fullPath), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                if (File.Exists(fullPath))
                {
                    MessageBox.Show(CultureService.Instance.GetString(CultureText.text_FileAlreadyExists) + "\n" + fullPath, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    DialogResult = DialogResult.OK;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void _0001_Symbol()
        {
            string msg;

            Assert.IsNull(ConsistencyCheck.Symbol("TEST_MESSAGE"));
            Assert.IsNull(ConsistencyCheck.Symbol("Test_Message"));
            Assert.IsNull(ConsistencyCheck.Symbol("TestMessage"));
            Assert.IsNull(ConsistencyCheck.Symbol("_TEST_MESSAGE"));
            Assert.IsNull(ConsistencyCheck.Symbol("B0123456789012345678901234567890"));

            CultureService.Instance.CurrentCultureName = "hu-HU";
            Assert.IsNotEmpty(msg = ConsistencyCheck.Symbol("B01234567890123456789012345678901"));
            Assert.AreEqual("Maximális szímbólum hossza: 32 karkter lehet.", msg); Console.WriteLine(msg);
            CultureService.Instance.CurrentCultureName = "en-US";
            Assert.IsNotEmpty(msg = ConsistencyCheck.Symbol("B01234567890123456789012345678901"));
            Assert.AreEqual("Symbol Name maximum lenght is: 32.", msg); Console.WriteLine(msg);


            Assert.IsNotEmpty(msg = ConsistencyCheck.Symbol(" TEST_MESSAGE"));
            Assert.IsNotEmpty(ConsistencyCheck.Symbol("0_TEST_MESSAGE"));
            Assert.IsNotEmpty(ConsistencyCheck.Symbol("?_TEST_MESSAGE"));
            Assert.IsNotEmpty(ConsistencyCheck.Symbol("UNICODE_Á_MESSAGE"));
        }
Beispiel #9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: org.neo4j.backup.impl.BackupOutcome executeBackup(org.neo4j.helpers.HostnamePort hostnamePort, java.nio.file.Path to, org.neo4j.backup.impl.ConsistencyCheck consistencyCheck, org.neo4j.kernel.configuration.Config config, long timeout, boolean forensics) throws ToolFailureException
        internal virtual BackupOutcome ExecuteBackup(HostnamePort hostnamePort, Path to, ConsistencyCheck consistencyCheck, Config config, long timeout, bool forensics)
        {
            try
            {
                _systemOut.println("Performing backup from '" + hostnamePort + "'");
                string host = hostnamePort.Host;
                int    port = hostnamePort.Port;

                BackupOutcome outcome = _backupProtocolService.doIncrementalBackupOrFallbackToFull(host, port, DatabaseLayout.of(to.toFile()), consistencyCheck, config, timeout, forensics);
                _systemOut.println("Done");
                return(outcome);
            }
            catch (Exception e) when(e is UnexpectedStoreVersionException || e is IncrementalBackupNotPossibleException)
            {
                throw new ToolFailureException(e.Message, e);
            }
            catch (MismatchingStoreIdException e)
            {
                throw new ToolFailureException(string.format(MISMATCHED_STORE_ID, e.Expected, e.Encountered));
            }
            catch (ComException e)
            {
                throw new ToolFailureException("Couldn't connect to '" + hostnamePort + "'", e);
            }
        }
Beispiel #10
0
 public BackupOutcome DoIncrementalBackup(string sourceHostNameOrIp, int sourcePort, DatabaseLayout databaseLayout, ConsistencyCheck consistencyCheck, long timeout, Config config) throws IncrementalBackupNotPossibleException
Beispiel #11
0
        private BackupOutcome FullBackup(FileSystemAbstraction fileSystem, string sourceHostNameOrIp, int sourcePort, DatabaseLayout targetLayout, ConsistencyCheck consistencyCheck, Config tuningConfiguration, long timeout, bool forensics)
        {
            try
            {
                if (!DirectoryIsEmpty(targetLayout))
                {
                    throw new Exception("Can only perform a full backup into an empty directory but " + targetLayout + " is not empty");
                }
                long timestamp       = DateTimeHelper.CurrentUnixTimeMillis();
                long lastCommittedTx = -1;
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                StoreCopyClient storeCopier = new StoreCopyClient(targetLayout, tuningConfiguration, LoadKernelExtensions(), _logProvider, fileSystem, _pageCacheContianer.PageCache, _monitors.newMonitor(typeof(StoreCopyClientMonitor), this.GetType().FullName), forensics);
                FullBackupStoreCopyRequester storeCopyRequester = new FullBackupStoreCopyRequester(sourceHostNameOrIp, sourcePort, timeout, forensics, _monitors);
                storeCopier.CopyStore(storeCopyRequester, Org.Neo4j.Helpers.CancellationRequest_Fields.NeverCancelled, MoveAfterCopy.moveReplaceExisting());

                tuningConfiguration.augment(logs_directory, targetLayout.databaseDirectory().toPath().toRealPath().ToString());
                File debugLogFile = tuningConfiguration.get(store_internal_log_path);
                BumpDebugDotLogFileVersion(debugLogFile, timestamp);
                bool consistent = CheckDbConsistency(fileSystem, targetLayout, consistencyCheck, tuningConfiguration, _pageCacheContianer.PageCache);
                ClearIdFiles(fileSystem, targetLayout);
                return(new BackupOutcome(lastCommittedTx, consistent));
            }
            catch (Exception e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new Exception(e);
            }
        }
Beispiel #12
0
 public BackupOutcome DoFullBackup(final string sourceHostNameOrIp, final int sourcePort, DatabaseLayout targetLayout, ConsistencyCheck consistencyCheck, Config tuningConfiguration, final long timeout, final bool forensics)
 {
     try
     {
         using (FileSystemAbstraction fileSystem = _fileSystemSupplier.get())
         {
             return(FullBackup(fileSystem, sourceHostNameOrIp, sourcePort, targetLayout, consistencyCheck, tuningConfiguration, timeout, forensics));
         }
     }
     catch (IOException e)
     {
         throw new Exception(e);
     }
 }