Esempio n. 1
0
CollectionType
collectionTypeFromName(vespalib::stringref name) {
    if (name == "SINGLE") { return CollectionType::SINGLE; }
    else if (name == "ARRAY") { return CollectionType::ARRAY; }
    else if (name == "WEIGHTEDSET") { return CollectionType::WEIGHTEDSET; }
    else {
        throw InvalidConfigException("Illegal enum value '" + name + "'");
    }
}
Esempio n. 2
0
int Upgrade::runUpgrade()
{
   App* app = Program::getApp();
   Config* config = app->getConfig();
   std::string storageDir = config->getStoreMetaDirectory();

   this->metaIdMap = Program::getApp()->getMetaStringIdMap();

   LogContext log("");
   log.logErr(""); // just an EOL
   log.logErr("* Writing log file to: " + config->getLogStdFile() );
   log.logErr("  Progress may be monitored by watching this file.");


   // loads target string to numeric ID map
   std::string targetIDMapFileName = Program::getApp()->getConfig()->getTargetIdMapFile();
   if (!loadIDMap(targetIDMapFileName, &this->targetIdMap) )
      return 1;

   bool deleteOldFiles = config->getDeleteOldFiles();
   if (!deleteOldFiles)
   {
      bool initRes = initInodesBackupDir(storageDir);
      if (!initRes)
         return 1;
   }

   if (!setLocalNodeNumID(this->metaIdMap) )
      return 1;

   log.logErr(""); // just an EOL
   log.logErr("* Starting the upgrade process: ...");
   log.logErr(""); // just an EOL

   bool retVal = migrateDentries(storageDir); // walks and calls migrateStructureSubdir()
   if(retVal == false || this->allOK == false)
   {
      log.logErr("");
      log.logErr("Not all dentries could be migrated. Remaining inodes will be ignored!");
      retVal = false;
      goto out;
   }

   if (!migrateInodes(storageDir) ) // migrate all (remaining) inodes
      retVal = false;


out:
   // storage format file
   if(!StorageTkEx::createStorageFormatFile(storageDir) )
      throw InvalidConfigException("Unable to create storage format file in: " + storageDir);

   printFinalInfo();

   return retVal;
}
Esempio n. 3
0
void App::daemonize() throw(InvalidConfigException)
{
   int nochdir = 1; // 1 to keep working directory
   int noclose = 0; // 1 to keep stdin/-out/-err open

   log->log(Log_DEBUG, std::string("Detaching process...") );

   int detachRes = daemon(nochdir, noclose);
   if(detachRes == -1)
      throw InvalidConfigException(std::string("Unable to detach process. SysErr: ") +
         System::getErrString() );
}
Esempio n. 4
0
/**
 * Compatibility and validity check of storage format file contents.
 *
 * @param pathStr path to the main storage working directory (not including a filename)
 * @throws exception if format file was not valid (eg didn't exist or contained wrong version).
 */
void StorageTkEx::checkStorageFormatFile(const std::string pathStr) throw(InvalidConfigException)
{
   App* app = Program::getApp();
   Config* cfg = app->getConfig();

   StringMap formatProperties;
   StringMapIter formatIter;

   StorageTk::checkAndUpdateStorageFormatFile(pathStr, STORAGETK_FORMAT_MIN_VERSION,
      STORAGETK_FORMAT_CURRENT_VERSION, &formatProperties);

   formatIter = formatProperties.find(STORAGETK_FORMAT_XATTR);
   if(formatIter == formatProperties.end() )
   {
      throw InvalidConfigException(std::string("Property missing from storage format file: ") +
         STORAGETK_FORMAT_XATTR " (dir: " + pathStr + ")");
   }

   if(cfg->getStoreUseExtendedAttribs() != StringTk::strToBool(formatIter->second) )
   {
      throw InvalidConfigException("Mismatch of extended attributes settings in storage format file"
         " and daemon config file.");
   }
}
Esempio n. 5
0
void App::initLocalNodeInfo() throw(InvalidConfigException)
{
   bool useSDP = this->cfg->getConnUseSDP();
   bool useRDMA = this->cfg->getConnUseRDMA();

   NetworkInterfaceCard::findAll(allowedInterfaces, useSDP, useRDMA, &localNicList);

   if(localNicList.empty() )
      throw InvalidConfigException("Couldn't find any usable NIC");

   localNicList.sort(&NetworkInterfaceCard::nicAddrPreferenceComp);

   std::string nodeID = System::getHostname() + "-" + StringTk::uint64ToHexStr(System::getPID() ) +
      "-" + StringTk::uintToHexStr(TimeAbs().getTimeMS() ) + "-" "ctl";

   localNode = new LocalNode(nodeID, 0, 0, 0, localNicList);

   localNode->setNodeType(NODETYPE_Client);
   localNode->setFhgfsVersion(BEEGFS_VERSION_CODE);
}
Esempio n. 6
0
void App::runNormal()
{
   bool componentsStarted = false;
   RunMode runMode;

   // init data objects
   initDataObjects(argc, argv);

   // check if mgmt host is defined if mode is not "help"
   runMode = this->cfg->determineRunMode();
   if ( (runMode != RunMode_INVALID) && !cfg->getSysMgmtdHost().length() )
      throw InvalidConfigException("Management host undefined");

   // tests
   if ( cfg->getDebugRunStartupTests() )
   {
      if ( !StartupTests::perform() )
      {
         this->log->log(1, "Startup Tests failed => shutting down...");
         appResult = APPCODE_RUNTIME_ERROR;
         return;
      }
   }

   // init components

   try
   {
      initComponents();

      // tests
      if(cfg->getDebugRunComponentTests() )
      {
         if(!ComponentTests::perform() )
         {
            this->log->log(1, "Component Tests failed => shutting down...");
            appResult = APPCODE_RUNTIME_ERROR;
            return;
         }
      }
   }
   catch(ComponentInitException& e)
   {
      log->logErr(e.what() );
      log->log(1, "A hard error occurred. Shutting down...");
      appResult = APPCODE_INITIALIZATION_ERROR;
      return;
   }


   // log system and configuration info

   logInfos();


   // detach process

   try
   {
      if(this->cfg->getRunDaemonized() )
         daemonize();
   }
   catch(InvalidConfigException& e)
   {
      log->logErr(e.what() );
      log->log(1, "A hard error occurred. Shutting down...");
      appResult = APPCODE_INVALID_CONFIG;
      return;
   }


   // start component threads

   if(this->cfg->getDebugRunComponentThreads() )
   {
      startComponents();

      componentsStarted = true;

      // tests
      if(cfg->getDebugRunIntegrationTests() )
      {
         if(!IntegrationTests::perform() )
         {
            this->log->log(1, "Integration Tests failed => shutting down...");
            appResult = APPCODE_RUNTIME_ERROR;

            stopComponents();
            goto err_joinAndExit;
         }
      }

      appResult = executeMode(runMode);

      // self-termination
      stopComponents();
   }


err_joinAndExit:
   if(componentsStarted)
   {
      joinComponents();
      log->log(3, "All components stopped. Exiting now!");
   }
}
Esempio n. 7
0
/**
 * @param addDashes true to prepend "--" to tested config keys for matching.
 */
void Config::applyConfigMap(bool enableException, bool addDashes) throw(InvalidConfigException)
{
   AbstractConfig::applyConfigMap(false, addDashes);

   for(StringMapIter iter = getConfigMap()->begin(); iter != getConfigMap()->end(); )
   {
      bool unknownElement = false;

      if (testConfigMapKeyMatch(iter, "mount", addDashes) )
      { // special argument to detect configuration file by mount point
         mount = iter->second;
         IoctlTk ioctl = IoctlTk(mount);
         if (!ioctl.getRuntimeCfgFile(&cfgFile))
            throw InvalidConfigException("Given mountpoint is invalid: " + mount);
      }
      else
      IGNORE_CONFIG_CLIENT_VALUE("logClientID")
      IGNORE_CONFIG_CLIENT_VALUE("logHelperdIP")
      if(testConfigMapKeyMatch(iter, "logEnabled", addDashes) )
         logEnabled = StringTk::strToBool(iter->second);
      else
      IGNORE_CONFIG_CLIENT_VALUE("logType")
      if(testConfigMapKeyMatch(iter, "connInterfacesFile", addDashes) )
         connInterfacesFile = iter->second;
      else
      IGNORE_CONFIG_CLIENT_VALUE("connNumCommRetries")
      IGNORE_CONFIG_CLIENT_VALUE("connUnmountRetries")
      IGNORE_CONFIG_CLIENT_VALUE("connCommRetrySecs")
      IGNORE_CONFIG_CLIENT_VALUE("connRecvNonIntrTimeoutMS")
      if(testConfigMapKeyMatch(iter, "debugRunComponentThreads", addDashes) )
         debugRunComponentThreads = StringTk::strToBool(iter->second);
      else
      if(testConfigMapKeyMatch(iter, "debugRunStartupTests", addDashes) )
         debugRunStartupTests = StringTk::strToBool(iter->second);
      else
      if(testConfigMapKeyMatch(iter, "debugRunComponentTests", addDashes) )
         debugRunComponentTests = StringTk::strToBool(iter->second);
      else
      if(testConfigMapKeyMatch(iter, "debugRunIntegrationTests", addDashes) )
         debugRunIntegrationTests = StringTk::strToBool(iter->second);
      else
      if(testConfigMapKeyMatch(iter, "debugRunThroughputTests", addDashes) )
         debugRunThroughputTests = StringTk::strToBool(iter->second);
      else
      if(testConfigMapKeyMatch(iter, "tuneNumWorkers", addDashes) )
         tuneNumWorkers = StringTk::strToUInt(iter->second);
      else
      IGNORE_CONFIG_CLIENT_VALUE("tuneNumRetryWorkers")
      if(testConfigMapKeyMatch(iter, "tunePreferredMetaFile", addDashes) )
         tunePreferredMetaFile = iter->second;
      else
      if(testConfigMapKeyMatch(iter, "tunePreferredStorageFile", addDashes) )
         tunePreferredStorageFile = iter->second;
      else
      IGNORE_CONFIG_CLIENT_VALUE("tuneFileCacheType")
      IGNORE_CONFIG_CLIENT_VALUE("tunePagedIOBufSize")
      IGNORE_CONFIG_CLIENT_VALUE("tunePagedIOBufNum")
      IGNORE_CONFIG_CLIENT_VALUE("tuneFileCacheBufSize")
      IGNORE_CONFIG_CLIENT_VALUE("tuneFileCacheBufNum")
      IGNORE_CONFIG_CLIENT_VALUE("tunePageCacheValidityMS")
      IGNORE_CONFIG_CLIENT_VALUE("tuneAttribCacheValidityMS")
      IGNORE_CONFIG_CLIENT_VALUE("tuneDirSubentryCacheValidityMS")
      IGNORE_CONFIG_CLIENT_VALUE("tuneFileSubentryCacheValidityMS")
      IGNORE_CONFIG_CLIENT_VALUE("tuneMaxWriteWorks")
      IGNORE_CONFIG_CLIENT_VALUE("tuneMaxReadWorks")
      IGNORE_CONFIG_CLIENT_VALUE("tuneAllowMultiSetWrite")
      IGNORE_CONFIG_CLIENT_VALUE("tuneAllowMultiSetRead")
      IGNORE_CONFIG_CLIENT_VALUE("tunePathBufSize")
      IGNORE_CONFIG_CLIENT_VALUE("tunePathBufNum")
      IGNORE_CONFIG_CLIENT_VALUE("tuneMaxReadWriteNum")
      IGNORE_CONFIG_CLIENT_VALUE("tuneMaxReadWriteNodesNum")
      IGNORE_CONFIG_CLIENT_VALUE("tuneMsgBufSize")
      IGNORE_CONFIG_CLIENT_VALUE("tuneMsgBufNum")
      IGNORE_CONFIG_CLIENT_VALUE("tuneRemoteFSync")
      IGNORE_CONFIG_CLIENT_VALUE("tuneUseGlobalFileLocks")
      IGNORE_CONFIG_CLIENT_VALUE("tuneRefreshOnGetAttr")
      IGNORE_CONFIG_CLIENT_VALUE("tuneInodeBlockBits")
      IGNORE_CONFIG_CLIENT_VALUE("tuneInodeBlockSize")
      IGNORE_CONFIG_CLIENT_VALUE("tuneMaxClientMirrorSize") // was removed, kept here for compat
      IGNORE_CONFIG_CLIENT_VALUE("tuneEarlyCloseResponse")
      IGNORE_CONFIG_CLIENT_VALUE("tuneUseGlobalAppendLocks")
      IGNORE_CONFIG_CLIENT_VALUE("tuneUseBufferedAppend")
      IGNORE_CONFIG_CLIENT_VALUE("tuneStatFsCacheSecs")
      IGNORE_CONFIG_CLIENT_VALUE("sysInodeIDStyle")
      IGNORE_CONFIG_CLIENT_VALUE("sysCreateHardlinksAsSymlinks")
      IGNORE_CONFIG_CLIENT_VALUE("sysMountSanityCheckMS")
      IGNORE_CONFIG_CLIENT_VALUE("sysSyncOnClose")
      IGNORE_CONFIG_CLIENT_VALUE("sysSessionCheckOnClose")
      IGNORE_CONFIG_CLIENT_VALUE("sysTargetOfflineTimeoutSecs")
      IGNORE_CONFIG_CLIENT_VALUE("sysXAttrsEnabled")
      IGNORE_CONFIG_CLIENT_VALUE("sysACLsEnabled")

      IGNORE_CONFIG_CLIENT_VALUE("quotaEnabled")
      if(testConfigMapKeyMatch(iter, "runDaemonized", addDashes) )
         runDaemonized = StringTk::strToBool(iter->second);
      else
      { // unknown element occurred
         unknownElement = true;

         if(enableException)
         {
            throw InvalidConfigException(
               std::string("The config argument '") + iter->first + std::string("' is invalid") );
         }
      }

      // advance iterator (and remove handled element)

      if(unknownElement)
      { // just skip the unknown element
         iter++;
      }
      else
      { // remove this element from the map
         iter = eraseFromConfigMap(iter);
      }
   }
}