コード例 #1
0
ファイル: paths.hpp プロジェクト: luisborges/mesos
inline std::string getTaskInfoPath(
    const std::string& rootDir,
    const SlaveID& slaveId,
    const FrameworkID& frameworkId,
    const ExecutorID& executorId,
    const UUID& executorUUID,
    const TaskID& taskId)
{
  return strings::format(
      TASK_INFO_PATH,
      rootDir,
      slaveId,
      frameworkId,
      executorId,
      executorUUID.toString(),
      taskId).get();
}
コード例 #2
0
void ASIOSocketWrapper::sendProtocolHeader(const MultiplexedSocketPtr&parentMultiSocket, const Address& address,  const UUID&value, unsigned int numConnections) {
//    if (paerntMultiSocket->isZeroDelim()) {
    std::stringstream header;
    header << "GET /" << value.toString() << " HTTP/1.1\r\n";
    header << "Upgrade: WebSocket\r\n";
    header << "Connection: Upgrade\r\n";

    std::string hostname=address.getHostName();
    for (std::string::iterator hi=hostname.begin(),he=hostname.end(); hi!=he; ++hi) {
        *hi=std::tolower(*hi);
    }
    header << "Host: " << hostname;
    if (address.getService()!="80")
        header << ":" << address.getService();
    header << "\r\n";

    header << "Origin: " << address.getHostName() << "\r\n";

    if (parentMultiSocket->getStreamType()!= TCPStream::RFC_6455) {
        header << "Sec-WebSocket-Key1: x!|6 j9  U 1 guf  36Y04  |   4\r\n";
        header << "Sec-WebSocket-Key2: 3   59   2 E4   _11  x80      \r\n";
    } else {
        header << "Sec-WebSocket-Version: 13\r\n";
        header << "Sec-WebSocket-Key: MTIzNDU2Nzg5MGFiY2RlZg==\r\n";
    }
    header << "Sec-WebSocket-Protocol: "
           << (parentMultiSocket->getStreamType()==TCPStream::BASE64_ZERODELIM?"wssst":"sst")
           << numConnections << "\r\n";
    header << "\r\n";
    if (parentMultiSocket->getStreamType()!= TCPStream::RFC_6455) {
        header << "abcdefgh";
    }

    std::string finalHeader(header.str());
    Chunk * headerData= new Chunk(finalHeader.begin(),finalHeader.end());
    rawSend(parentMultiSocket,headerData,true);
    /*
        }else {
            UUID return_value=(parentMultiSocket->isZeroDelim()?massageUUID(UUID::random()):UUID::random());

            Chunk *headerData=new Chunk(TCPStream::TcpSstHeaderSize);
            copyHeader(&*headerData->begin(),parentMultiSocket->isZeroDelim()?TCPStream::WEBSOCKET_STRING_PREFIX():TCPStream::STRING_PREFIX(),value,numConnections);
            rawSend(parentMultiSocket,headerData,true);
        }
    */
}
コード例 #3
0
/*
  This is the function that we use to add an object.  generateAck is true if you want to generate an ack message to server idServerAckTo

  If you're initially adding an object to the world, you should use the newObjectAdd function instead.
*/
void CraqObjectSegmentation::addMigratedObject(const UUID& obj_id, float radius, ServerID idServerAckTo, bool generateAck)
{
    if (mStopping)
        return;


    if (generateAck)
    {
        CraqDataKey cdk;
        convert_obj_id_to_dht_key(obj_id,cdk);

        CraqDataSetGet cdSetGet(cdk, CraqEntry(mContext->id(),radius) ,true,CraqDataSetGet::SET);

        receivingObjects_m.lock();
        mReceivingObjects.insert(ObjectSet::value_type(obj_id,CraqEntry(mContext->id(),radius)));
        receivingObjects_m.unlock();

        TrackedSetResultsData tsrd;
        tsrd.migAckMsg = generateAcknowledgeMessage(obj_id, radius, idServerAckTo);
        tsrd.dur =  Time::local() - Time::epoch();

        int trackID = getUniqueTrackID();
        craqDhtSet.set(cdSetGet,trackID);
        trackingMessages[trackID] = tsrd;
    }
    else
    {
        //potentially clean up: we should really only be adding objects without generating acks using the newObjectAdd interface
        CraqDataKey cdk;
        convert_obj_id_to_dht_key(obj_id,cdk);

        CraqDataSetGet cdSetGet(cdk, CraqEntry(mContext->id(),radius) ,false,CraqDataSetGet::SET);
        int trackID = getUniqueTrackID();
        craqDhtSet.set(cdSetGet, trackID);


        std::pair<ObjectSet::iterator, bool> inserted = mObjects.insert(ObjectSet::value_type(obj_id,CraqEntry(mContext->id(),radius)));
        if (inserted.second)
        {
            std::cout<<"\n\nAdding object:  "<<obj_id.toString()<<"\n";
        }
    }
}
コード例 #4
0
ファイル: SpellData.cpp プロジェクト: metsfan/dungeon-raider
	void SpellData::GetSpellById(const UUID &id, std::function<void(SpellDataPtr)> success, APIFailureCallback failure)
	{
		APIRequestManager *manager = APIRequestManager::GetDefaultManager();
		std::stringstream url;
		url << "/spell/" << id.toString();

		manager->Send(url.str(), "GET", "", [success](std::istream &stream) {
			Poco::JSON::Parser parser;

			auto object = parser.parse(stream).extract<JSONObject::Ptr>();
			auto data = std::make_shared<SpellData>();
			data->FromJSON(object);

			success(data);

		}, [failure](const std::string &error)  {
			failure(error);
		});
	}
コード例 #5
0
std::pair<BSONObj, RecordId> RollbackTest::makeCRUDOp(OpTypeEnum opType,
                                                      Timestamp ts,
                                                      UUID uuid,
                                                      StringData nss,
                                                      BSONObj o,
                                                      boost::optional<BSONObj> o2,
                                                      int recordId) {
    invariant(opType != OpTypeEnum::kCommand);

    BSONObjBuilder bob;
    bob.append("ts", ts);
    bob.append("op", OpType_serializer(opType));
    uuid.appendToBuilder(&bob, "ui");
    bob.append("ns", nss);
    bob.append("o", o);
    if (o2) {
        bob.append("o2", *o2);
    }

    return std::make_pair(bob.obj(), RecordId(recordId));
}
コード例 #6
0
ModuleSP
ModuleList::FindModule (const UUID &uuid) const
{
    ModuleSP module_sp;
    
    if (uuid.IsValid())
    {
        Mutex::Locker locker(m_modules_mutex);
        collection::const_iterator pos, end = m_modules.end();
        
        for (pos = m_modules.begin(); pos != end; ++pos)
        {
            if ((*pos)->GetUUID() == uuid)
            {
                module_sp = (*pos);
                break;
            }
        }
    }
    return module_sp;
}
コード例 #7
0
void SQLitePersistedObjectSet::performUpdate(const UUID& internal_id, const String& script_type, const String& script_args, const String& script_contents, RequestCallback cb) {
    bool success = true;

    int rc;
    char* remain;
    String value_insert;
    value_insert = "INSERT OR REPLACE INTO ";
    value_insert += "\"" TABLE_NAME "\"";
    value_insert += " (object, script_type, script_args, script_contents) VALUES(?, ?, ?, ?)";

    sqlite3_stmt* value_insert_stmt;
    rc = sqlite3_prepare_v2(mDB->db(), value_insert.c_str(), -1, &value_insert_stmt, (const char**)&remain);
    success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error preparing value insert statement");

    String id_str = internal_id.rawHexData();
    rc = sqlite3_bind_text(value_insert_stmt, 1, id_str.c_str(), (int)id_str.size(), SQLITE_TRANSIENT);
    success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error binding object internal ID to value insert statement");
    rc = sqlite3_bind_text(value_insert_stmt, 2, script_type.c_str(), (int)script_type.size(), SQLITE_TRANSIENT);
    success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error binding script_type name to value insert statement");
    rc = sqlite3_bind_blob(value_insert_stmt, 3, script_args.c_str(), (int)script_args.size(), SQLITE_TRANSIENT);
    success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error binding script_args to value insert statement");
    rc = sqlite3_bind_blob(value_insert_stmt, 4, script_contents.c_str(), (int)script_contents.size(), SQLITE_TRANSIENT);
    success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error binding script_contents to value insert statement");

    int step_rc = SQLITE_OK;
    while(step_rc == SQLITE_OK) {
        step_rc = sqlite3_step(value_insert_stmt);
    }
    if (step_rc != SQLITE_OK && step_rc != SQLITE_DONE) {
        success = false;
        sqlite3_reset(value_insert_stmt); // allow this to be cleaned
                                          // up
    }

    rc = sqlite3_finalize(value_insert_stmt);
    success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error finalizing value insert statement");

    if (cb != 0)
        mContext->mainStrand->post(std::tr1::bind(cb, success), "SQLitePersistedObjectSet::performUpdate callback");
}
コード例 #8
0
void SubgraphNode::setupParameters(Parameterizable& params)
{
    setupVariadicParameters(params);

    params.addParameter(param::factory::declareBool("iterate_containers", param::ParameterDescription("When true, input vectors will be iterated internally"), false));

    std::map<std::string, std::pair<int, bool> > flags;

    iterated_inputs_param_ = std::dynamic_pointer_cast<param::BitSetParameter>(param::factory::declareParameterBitSet("iterated_containers", flags).build());

    params.addConditionalParameter(iterated_inputs_param_, [this]() { return readParameter<bool>("iterate_containers"); },
                                   [this](param::Parameter* p) {
                                       for (auto& pair : relay_to_external_input_) {
                                           UUID id = pair.second;
                                           InputPtr i = node_handle_->getInput(id);
                                           apex_assert_hard(i);

                                           bool iterate = iterated_inputs_param_->isSet(id.getFullName());
                                           setIterationEnabled(id, iterate);
                                       }
                                   });
}
コード例 #9
0
ファイル: ModuleCache.cpp プロジェクト: karwa/swift-lldb
ModuleLock::ModuleLock(const FileSpec &root_dir_spec, const UUID &uuid,
                       Error &error) {
  const auto lock_dir_spec = JoinPath(root_dir_spec, kLockDirName);
  error = MakeDirectory(lock_dir_spec);
  if (error.Fail())
    return;

  m_file_spec = JoinPath(lock_dir_spec, uuid.GetAsString().c_str());
  m_file.Open(m_file_spec.GetCString(), File::eOpenOptionWrite |
                                            File::eOpenOptionCanCreate |
                                            File::eOpenOptionCloseOnExec);
  if (!m_file) {
    error.SetErrorToErrno();
    return;
  }

  m_lock.reset(new lldb_private::LockFile(m_file.GetDescriptor()));
  error = m_lock->WriteLock(0, 1);
  if (error.Fail())
    error.SetErrorStringWithFormat("Failed to lock file: %s",
                                   error.AsCString());
}
コード例 #10
0
ファイル: UUID.cpp プロジェクト: WilliamDrewAeroNomos/muthur
bool UUID::equals( const UUID& value ) const {
    return this->getMostSignificantBits() == value.getMostSignificantBits() &&
           this->getLeastSignificantBits() == value.getLeastSignificantBits();
}
コード例 #11
0
ファイル: UUID.cpp プロジェクト: WilliamDrewAeroNomos/muthur
int UUID::compareTo( const UUID& value ) const {
    return apr_strnatcmp( this->toString().c_str(), value.toString().c_str() );
}
コード例 #12
0
Property::Property (const PropertyDefinition &definition) :
    m_name (definition.name),
    m_description (definition.description),
    m_value_sp (),
    m_is_global (definition.global)
{
    switch (definition.type)
    {
        case OptionValue::eTypeInvalid:
        case OptionValue::eTypeProperties:
            break;
        case OptionValue::eTypeArch:
            // "definition.default_uint_value" is not used
            // "definition.default_cstr_value" as a string value that represents the default string value for the architecture/triple
            m_value_sp.reset (new OptionValueArch(definition.default_cstr_value));
            break;
            
        case OptionValue::eTypeArgs:
            // "definition.default_uint_value" is always a OptionValue::Type
            m_value_sp.reset (new OptionValueArgs());
            break;
            
        case OptionValue::eTypeArray:
            // "definition.default_uint_value" is always a OptionValue::Type
            m_value_sp.reset (new OptionValueArray(OptionValue::ConvertTypeToMask((OptionValue::Type)definition.default_uint_value)));
            break;
            
        case OptionValue::eTypeBoolean:
            // "definition.default_uint_value" is the default boolean value if
            // "definition.default_cstr_value" is NULL, otherwise interpret
            // "definition.default_cstr_value" as a string value that represents the default
            // value.
            if (definition.default_cstr_value)
                m_value_sp.reset (new OptionValueBoolean(Args::StringToBoolean (definition.default_cstr_value, false, nullptr)));
            else
                m_value_sp.reset (new OptionValueBoolean(definition.default_uint_value != 0));
            break;
            
        case OptionValue::eTypeDictionary:
            // "definition.default_uint_value" is always a OptionValue::Type
            m_value_sp.reset (new OptionValueDictionary(OptionValue::ConvertTypeToMask((OptionValue::Type)definition.default_uint_value)));
            break;
            
        case OptionValue::eTypeEnum:
            // "definition.default_uint_value" is the default enumeration value if
            // "definition.default_cstr_value" is NULL, otherwise interpret
            // "definition.default_cstr_value" as a string value that represents the default
            // value.
        {
            OptionValueEnumeration *enum_value = new OptionValueEnumeration(definition.enum_values, definition.default_uint_value);
            m_value_sp.reset (enum_value);
            if (definition.default_cstr_value)
            {
                if (enum_value->SetValueFromCString(definition.default_cstr_value).Success())
                {
                    enum_value->SetDefaultValue(enum_value->GetCurrentValue());
                    // Call Clear() since we don't want the value to appear as
                    // having been set since we called SetValueFromCString() above.
                    // Clear will set the current value to the default and clear
                    // the boolean that says that the value has been set.
                    enum_value->Clear();
                }
            }
        }
            break;
            
        case OptionValue::eTypeFileSpec:
            // "definition.default_uint_value" represents if the "definition.default_cstr_value" should
            // be resolved or not
            m_value_sp.reset (new OptionValueFileSpec(FileSpec(definition.default_cstr_value, definition.default_uint_value != 0)));
            break;
            
        case OptionValue::eTypeFileSpecList:
            // "definition.default_uint_value" is not used for a OptionValue::eTypeFileSpecList
            m_value_sp.reset (new OptionValueFileSpecList());
            break;
            
        case OptionValue::eTypeFormat:
            // "definition.default_uint_value" is the default format enumeration value if
            // "definition.default_cstr_value" is NULL, otherwise interpret
            // "definition.default_cstr_value" as a string value that represents the default
            // value.
        {
            Format new_format = eFormatInvalid;
            if (definition.default_cstr_value)
                Args::StringToFormat (definition.default_cstr_value, new_format, nullptr);
            else
                new_format = (Format)definition.default_uint_value;
            m_value_sp.reset (new OptionValueFormat(new_format));
        }
            break;
            
        case OptionValue::eTypePathMap:
            // "definition.default_uint_value" tells us if notifications should occur for
            // path mappings
            m_value_sp.reset (new OptionValuePathMappings(definition.default_uint_value != 0));
            break;
            
        case OptionValue::eTypeRegex:
            // "definition.default_uint_value" is used to the regular expression flags
            // "definition.default_cstr_value" the default regular expression value
            // value.
            m_value_sp.reset (new OptionValueRegex(definition.default_cstr_value, definition.default_uint_value));
            break;
            
        case OptionValue::eTypeSInt64:
            // "definition.default_uint_value" is the default integer value if
            // "definition.default_cstr_value" is NULL, otherwise interpret
            // "definition.default_cstr_value" as a string value that represents the default
            // value.
            m_value_sp.reset (new OptionValueSInt64(definition.default_cstr_value ? Args::StringToSInt64 (definition.default_cstr_value) : definition.default_uint_value));
            break;
            
        case OptionValue::eTypeUInt64:
            // "definition.default_uint_value" is the default unsigned integer value if
            // "definition.default_cstr_value" is NULL, otherwise interpret
            // "definition.default_cstr_value" as a string value that represents the default
            // value.
            m_value_sp.reset (new OptionValueUInt64(definition.default_cstr_value ? Args::StringToUInt64 (definition.default_cstr_value) : definition.default_uint_value));
            break;
            
        case OptionValue::eTypeUUID:
            // "definition.default_uint_value" is not used for a OptionValue::eTypeUUID
            // "definition.default_cstr_value" can contain a default UUID value
        {
            UUID uuid;
            if (definition.default_cstr_value)
                uuid.SetFromCString (definition.default_cstr_value);
            m_value_sp.reset (new OptionValueUUID(uuid));
        }
            break;
            
        case OptionValue::eTypeString:
            // "definition.default_uint_value" can contain the string option flags OR'ed together
            // "definition.default_cstr_value" can contain a default string value
            {
                OptionValueString *string_value = new OptionValueString(definition.default_cstr_value);
                if (definition.default_uint_value != 0)
                    string_value->GetOptions().Reset(definition.default_uint_value);
                m_value_sp.reset (string_value);
            }
            break;
    }
}
コード例 #13
0
void CraqObjectSegmentation::convert_obj_id_to_dht_key(const UUID& obj_id, CraqDataKey& returner) const
{
    returner[0] = myUniquePrefixKey;
    strncpy(returner+1,obj_id.rawHexData().c_str(),obj_id.rawHexData().size() + 1);
}
コード例 #14
0
/*
  If we get a message to move an object that our server holds, then we add the object's id to mInTransit.
  Whatever calls this must verify that the object is on this server.
  I can do the check in the function by querrying bambooDht as well
*/
void CraqObjectSegmentation::migrateObject(const UUID& obj_id, const OSegEntry& new_server_id)
{
    if (mStopping)
        return;

    //log the message.
    CONTEXT_SPACETRACE(objectBeginMigrate,
                       obj_id,mContext->id(),
                       new_server_id.server());

    InTransitMap::const_iterator transIter = mInTransitOrLookup.find(obj_id);

    TransLookup tmpTransLookup;
    tmpTransLookup.sID = CraqEntry(new_server_id);

    Duration tmpDurer = Time::local() - Time::epoch();

    tmpTransLookup.timeAdmitted = (int)tmpDurer.toMilliseconds();

    mInTransitOrLookup[obj_id] = tmpTransLookup;

    //erases the local copy of obj_id
    UUID tmp_id = obj_id; //note: can probably delete this line

    //erase the local copy of the object.
    size_t num_erased = mObjects.erase(obj_id);
#ifdef CRAQ_DEBUG
    if (num_erased == 0)
    {
        std::cout<<"\n\nThe object clearly wasn't registered on this server.  This is obj id:  " <<  obj_id.toString() <<  ".  This is time:   " <<mContext->simTime().raw() << " Oh no.   ";

        if (clearToMigrate(obj_id))
            std::cout<<"  Likely a problem with clear to migrate\n\n";
        else
            std::cout<<"\n\n clear to migrate is fine migration is being called from somewhere besides server.cpp\n\n";
    }
#endif
}
コード例 #15
0
dmz::Config
dmz::ArchivePluginObject::_archive_object (const Handle ObjectHandle) {

   Config result;

   ObjectModule *objMod (get_object_module ());

   if (objMod) {

      Config tmp ("object");

      Boolean archiveObject (True);

      const ObjectType Type (objMod->lookup_object_type (ObjectHandle));

      if (Type) {

         if (_currentFilterList) {

            FilterStruct *filter = _currentFilterList->list;

            while (filter) {

               if (filter->mode & LocalExportMask) {

                  if (filter->exTypes.get_count () &&
                        filter->exTypes.contains_type (Type)) {

                     archiveObject = False;
                     filter = 0;
                  }

                  if (filter && filter->inTypes.get_count () &&
                        !filter->inTypes.contains_type (Type)) {

                     archiveObject = False;
                     filter = 0;
                  }
               }

               if (filter) { filter = filter->next; }
            }
         }
      }
      else { archiveObject = False; }

      if (archiveObject) {

         tmp.store_attribute ("type", Type.get_name ());

         UUID uuid;

         if (objMod->lookup_uuid (ObjectHandle, uuid)) {

            tmp.store_attribute ("uuid", uuid.to_string ());
         }

         _currentConfig = result = tmp;

         objMod->dump_all_object_attributes (ObjectHandle, *this);
      }
   }

   _attrTable.empty ();
   _currentConfig.set_config_context (0);

   return result;
}
コード例 #16
0
void BlueNRGGattClient::serviceCharByUUIDCB(Gap::Handle_t connectionHandle,
                                            uint8_t event_data_length,
                                            uint16_t attr_handle,
                                            uint8_t *attr_value)
{
  // Charac Properties(1), Charac Value Handle(2), Charac UUID(2/16)
  GattAttribute::Handle_t declHandle, valueHandle;
  UUID uuid;
  
  PRINTF("serviceCharByUUIDCB\n\r");
  
  // UUID Type
  if (event_data_length == 7) {
    PRINTF("Char UUID_TYPE_16\n\r");
    uuid = attr_value[4]<<8|attr_value[3];
    PRINTF("C UUID-%X\r\n", uuid.getShortUUID());
  } else {
    PRINTF("Char UUID_TYPE_128\n\r");
    uuid.setupLong(attr_value+3);
    PRINTF("C UUID-");
#ifdef DEBUG
    const uint8_t *longUUIDBytes = uuid.getBaseUUID();
    for (unsigned i = 0; i < UUID::LENGTH_OF_LONG_UUID; i++) {
      PRINTF("%02X", longUUIDBytes[i]);
    }
    PRINTF("\r\n");
#endif
  }

  // Properties
  DiscoveredCharacteristic::Properties_t p;
  
  p._broadcast = (props_mask[0] & attr_value[0]);
  p._read = (props_mask[1] & attr_value[0])>>1;
  p._writeWoResp = (props_mask[2] & attr_value[0])>>2;
  p._write = (props_mask[3] & attr_value[0])>>3;
  p._notify = (props_mask[4] & attr_value[0])>>4;
  p._indicate = (props_mask[5] & attr_value[0])>>5;
  p._authSignedWrite = (props_mask[6] & attr_value[0])>>6;
  PRINTF("p._broadcast=%d\n\r", p._broadcast);
  PRINTF("p._read=%d\n\r", p._read);
  PRINTF("p._writeWoResp=%d\n\r", p._writeWoResp);
  PRINTF("p._write=%d\n\r", p._write);
  PRINTF("p._notify=%d\n\r", p._notify);
  PRINTF("p._indicate=%d\n\r", p._indicate);
  PRINTF("p._authSignedWrite=%d\n\r", p._authSignedWrite);

  /*
  uint8_t props = attr_value[0];
  PRINTF("CHAR PROPS: %d\n\r", props);
  */

  // Handles
  declHandle = attr_handle;
  valueHandle = attr_value[1];

  discoveredChar[_numChars].setup(this,
                                  connectionHandle,
                                  uuid,
                                  p,
                                  declHandle,
                                  valueHandle);
  
  if(characteristicDiscoveryCallback) {
    characteristicDiscoveryCallback(&discoveredChar[_numChars]);
  }
  _numChars++;
}
コード例 #17
0
ファイル: tpm.cpp プロジェクト: fxdupont/botan
std::string format_url(const UUID& uuid, TPM_Storage_Type storage)
   {
   std::string storage_str = (storage == TPM_Storage_Type::User) ? "user" : "system";
   return "tpmkey:uuid=" + uuid.to_string() + ";storage=" + storage_str;
   }
コード例 #18
0
/** Loads a plaintext file that was created by MyPasswordSafe.
 */
Safe::Error PlainTextLizer::load(Safe &safe, const QString &path, const EncryptedString &passphrase, const QString &)
{
  QFile file(path);
  if(file.open(QIODevice::ReadOnly)) {
    QTextStream stream(&file);
    stream.setEncoding(QTextStream::UnicodeUTF8);
    QString line;

    line = stream.readLine();
    if(EncryptedString(line.utf8()) != passphrase)
      return Safe::Failed; // passphrase was invalid

    while(!stream.atEnd()) {
      line = stream.readLine();
      QStringList items = QStringList::split('\t', line, true);
      DBGOUT("items.count = " << items.count());
      if(items.count() == 9) {
	SafeGroup *group = findOrCreateGroup(&safe, field(items, 3));
	if(group == NULL)
	  group = &safe;

	SafeEntry *item = new SafeEntry(group);
	item->setName(field(items, 0));
	item->setUser(field(items, 1));
	item->setPassword(field(items, 2).utf8());
	item->setCreationTime(QDateTime::fromString(field(items, 4), Qt::ISODate));
	item->setModifiedTime(QDateTime::fromString(field(items, 5), Qt::ISODate));
	item->setAccessTime(QDateTime::fromString(field(items, 6), Qt::ISODate));
	item->setLifetime(QTime::fromString(field(items, 7), Qt::ISODate));

	UUID uuid;
	uuid.fromString(field(items, 8));
	item->setUUID(uuid);

	line = stream.readLine();
	line.replace("\\n", "\n");
	item->setNotes(line);
      }
      else {
	file.close();
	return Safe::BadFile;
      }
    }

    file.close();
    return Safe::Success;
  }

  return Safe::BadFile;
#if 0
  ifstream file(path);
  if(file.is_open()) {
    string line;
    getline(file, line, '\n');


    while(!file.eof()) {
      getline(file, line, '\n');
      //if(items.size() == 4)
      //	safe_item.setGroup(items[3]);
    }

    file.close();
    return Safe::Success;
  }
#endif
  return Safe::Failed;
}
コード例 #19
0
bool DynamicLoaderMacOSXDYLD::GetSharedCacheInformation(
    lldb::addr_t &base_address, UUID &uuid, LazyBool &using_shared_cache,
    LazyBool &private_shared_cache) {
  base_address = LLDB_INVALID_ADDRESS;
  uuid.Clear();
  using_shared_cache = eLazyBoolCalculate;
  private_shared_cache = eLazyBoolCalculate;

  if (m_process) {
    addr_t all_image_infos = m_process->GetImageInfoAddress();

    // The address returned by GetImageInfoAddress may be the address of dyld
    // (don't want) or it may be the address of the dyld_all_image_infos
    // structure (want). The first four bytes will be either the version field
    // (all_image_infos) or a Mach-O file magic constant. Version 13 and higher
    // of dyld_all_image_infos is required to get the sharedCacheUUID field.

    Status err;
    uint32_t version_or_magic =
        m_process->ReadUnsignedIntegerFromMemory(all_image_infos, 4, -1, err);
    if (version_or_magic != static_cast<uint32_t>(-1) &&
        version_or_magic != llvm::MachO::MH_MAGIC &&
        version_or_magic != llvm::MachO::MH_CIGAM &&
        version_or_magic != llvm::MachO::MH_MAGIC_64 &&
        version_or_magic != llvm::MachO::MH_CIGAM_64 &&
        version_or_magic >= 13) {
      addr_t sharedCacheUUID_address = LLDB_INVALID_ADDRESS;
      int wordsize = m_process->GetAddressByteSize();
      if (wordsize == 8) {
        sharedCacheUUID_address =
            all_image_infos + 160; // sharedCacheUUID <mach-o/dyld_images.h>
      }
      if (wordsize == 4) {
        sharedCacheUUID_address =
            all_image_infos + 84; // sharedCacheUUID <mach-o/dyld_images.h>
      }
      if (sharedCacheUUID_address != LLDB_INVALID_ADDRESS) {
        uuid_t shared_cache_uuid;
        if (m_process->ReadMemory(sharedCacheUUID_address, shared_cache_uuid,
                                  sizeof(uuid_t), err) == sizeof(uuid_t)) {
          uuid = UUID::fromOptionalData(shared_cache_uuid, 16);
          if (uuid.IsValid()) {
            using_shared_cache = eLazyBoolYes;
          }
        }

        if (version_or_magic >= 15) {
          // The sharedCacheBaseAddress field is the next one in the
          // dyld_all_image_infos struct.
          addr_t sharedCacheBaseAddr_address = sharedCacheUUID_address + 16;
          Status error;
          base_address = m_process->ReadUnsignedIntegerFromMemory(
              sharedCacheBaseAddr_address, wordsize, LLDB_INVALID_ADDRESS,
              error);
          if (error.Fail())
            base_address = LLDB_INVALID_ADDRESS;
        }

        return true;
      }

      //
      // add
      // NB: sharedCacheBaseAddress is the next field in dyld_all_image_infos
      // after
      // sharedCacheUUID -- that is, 16 bytes after it, if we wanted to fetch
      // it.
    }
  }
  return false;
}
コード例 #20
0
ファイル: UUID.cpp プロジェクト: alepez/bmrk
UUID makeUUID() {
	UUID v;
	auto u = boost::uuids::random_generator()();
	std::copy(u.begin(), u.end(), v.begin());
	return v;
}
コード例 #21
0
void
dmz::ArchivePluginObject::_config_to_object (Config &objData) {

   ObjectModule *objMod (get_object_module ());

   if (objMod) {

      const UUID ObjUUID (config_to_string ("uuid", objData));
      String objectName (config_to_string ("name", objData));
      if (!objectName) { objectName = ObjUUID.to_string (); }

      const String TypeName (config_to_string ("type", objData));
      const ObjectType Type (TypeName, get_plugin_runtime_context ());

      Boolean filterObject (False);

      if (_currentFilterList) {

         FilterStruct *filter = _currentFilterList->list;

         while (filter) {

            if (filter->mode & LocalImportMask) {

               if (filter->exTypes.get_count () &&
                     filter->exTypes.contains_type (Type)) {

                  filterObject = True;
                  filter = 0;
               }

               if (filter && filter->inTypes.get_count () &&
                     !filter->inTypes.contains_type (Type)) {

                  filterObject = True;
                  filter = 0;
               }
            }

            if (filter) { filter = filter->next; }
         }
      }

      if (Type && !filterObject) {

         Handle objectHandle (0);

         if (ObjUUID) { objectHandle = objMod->lookup_handle_from_uuid (ObjUUID); }

         if (!objectHandle) { objectHandle = objMod->create_object (Type, ObjectLocal); }

         if (objectHandle) {

            if (ObjUUID) { objMod->store_uuid (objectHandle, ObjUUID); }

            ObjectLinkStruct *links (0);

            if (objectName) {

               links = new ObjectLinkStruct (objectHandle);

               if (links && !_linkTable.store (objectName, links)) {

                  delete links; links = 0;
               }
            }

            Config attrList;

            if (objData.lookup_all_config ("attributes", attrList)) {

               ConfigIterator it;

               Config attrData;

               Boolean found (attrList.get_first_config (it, attrData));

               while (found) {

                  _store_object_attributes (objectHandle, attrData, links);
                  found = attrList.get_next_config (it, attrData);
               }
            }

            objMod->activate_object (objectHandle);
         }
         else {

            _log.error << "Unable to create object of type: " << TypeName << endl;
         }
      }
      else if (!Type) {

         _log.error << "Unable to create object of unknown type: " << TypeName << endl;
      }
      else {

         _log.info << "Filtering object with type: " << TypeName << endl;
      }
   }
}
コード例 #22
0
ファイル: object.cpp プロジェクト: rttag/Collage
void Object::setID( const UUID& identifier )
{
    LBASSERT( !isAttached( ));
    LBASSERT( identifier.isGenerated( ));
    impl_->id = identifier;
}
コード例 #23
0
ファイル: UUID.cpp プロジェクト: ice799/lldb
bool
lldb_private::operator >= (const UUID &lhs, const UUID &rhs)
{
    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), UUID::GetByteSize()) >= 0;
}
コード例 #24
0
ファイル: CFPP-UUID.cpp プロジェクト: BaroboRobotics/CFPP
 bool UUID::operator == ( const UUID & value ) const
 {
     return this->GetString() == value.GetString();
 }
コード例 #25
0
ファイル: WAVE.cpp プロジェクト: matthiasr/audiofile
status WAVEFile::parseFormat(const Tag &id, uint32_t size)
{
	Track *track = getTrack();

	uint16_t formatTag;
	readU16(&formatTag);
	uint16_t channelCount;
	readU16(&channelCount);
	uint32_t sampleRate;
	readU32(&sampleRate);
	uint32_t averageBytesPerSecond;
	readU32(&averageBytesPerSecond);
	uint16_t blockAlign;
	readU16(&blockAlign);

	track->f.channelCount = channelCount;
	track->f.sampleRate = sampleRate;
	track->f.byteOrder = AF_BYTEORDER_LITTLEENDIAN;

	/* Default to uncompressed audio data. */
	track->f.compressionType = AF_COMPRESSION_NONE;

	switch (formatTag)
	{
		case WAVE_FORMAT_PCM:
		{
			uint16_t bitsPerSample;
			readU16(&bitsPerSample);

			track->f.sampleWidth = bitsPerSample;

			if (bitsPerSample == 0 || bitsPerSample > 32)
			{
				_af_error(AF_BAD_WIDTH,
					"bad sample width of %d bits",
					bitsPerSample);
				return AF_FAIL;
			}

			if (bitsPerSample <= 8)
				track->f.sampleFormat = AF_SAMPFMT_UNSIGNED;
			else
				track->f.sampleFormat = AF_SAMPFMT_TWOSCOMP;
		}
		break;

		case WAVE_FORMAT_MULAW:
		case IBM_FORMAT_MULAW:
			track->f.sampleWidth = 16;
			track->f.sampleFormat = AF_SAMPFMT_TWOSCOMP;
			track->f.byteOrder = _AF_BYTEORDER_NATIVE;
			track->f.compressionType = AF_COMPRESSION_G711_ULAW;
			break;

		case WAVE_FORMAT_ALAW:
		case IBM_FORMAT_ALAW:
			track->f.sampleWidth = 16;
			track->f.sampleFormat = AF_SAMPFMT_TWOSCOMP;
			track->f.byteOrder = _AF_BYTEORDER_NATIVE;
			track->f.compressionType = AF_COMPRESSION_G711_ALAW;
			break;

		case WAVE_FORMAT_IEEE_FLOAT:
		{
			uint16_t bitsPerSample;
			readU16(&bitsPerSample);

			if (bitsPerSample == 64)
			{
				track->f.sampleWidth = 64;
				track->f.sampleFormat = AF_SAMPFMT_DOUBLE;
			}
			else
			{
				track->f.sampleWidth = 32;
				track->f.sampleFormat = AF_SAMPFMT_FLOAT;
			}
		}
		break;

		case WAVE_FORMAT_ADPCM:
		{
			uint16_t bitsPerSample, extraByteCount,
					samplesPerBlock, numCoefficients;

			if (track->f.channelCount != 1 &&
				track->f.channelCount != 2)
			{
				_af_error(AF_BAD_CHANNELS,
					"WAVE file with MS ADPCM compression "
					"must have 1 or 2 channels");
			}

			readU16(&bitsPerSample);
			readU16(&extraByteCount);
			readU16(&samplesPerBlock);
			readU16(&numCoefficients);

			/* numCoefficients should be at least 7. */
			assert(numCoefficients >= 7 && numCoefficients <= 255);

			for (int i=0; i<numCoefficients; i++)
			{
				int16_t a0, a1;

				readS16(&a0);
				readS16(&a1);

				msadpcmCoefficients[i][0] = a0;
				msadpcmCoefficients[i][1] = a1;
			}

			track->f.sampleWidth = 16;
			track->f.sampleFormat = AF_SAMPFMT_TWOSCOMP;
			track->f.compressionType = AF_COMPRESSION_MS_ADPCM;
			track->f.byteOrder = _AF_BYTEORDER_NATIVE;

			/* Create the parameter list. */
			long l;
			void *v;
			AUpvlist pv = AUpvnew(4);
			AUpvsetparam(pv, 0, _AF_MS_ADPCM_NUM_COEFFICIENTS);
			AUpvsetvaltype(pv, 0, AU_PVTYPE_LONG);
			l = numCoefficients;
			AUpvsetval(pv, 0, &l);

			AUpvsetparam(pv, 1, _AF_MS_ADPCM_COEFFICIENTS);
			AUpvsetvaltype(pv, 1, AU_PVTYPE_PTR);
			v = msadpcmCoefficients;
			AUpvsetval(pv, 1, &v);

			AUpvsetparam(pv, 2, _AF_FRAMES_PER_BLOCK);
			AUpvsetvaltype(pv, 2, AU_PVTYPE_LONG);
			l = samplesPerBlock;
			AUpvsetval(pv, 2, &l);

			AUpvsetparam(pv, 3, _AF_BLOCK_SIZE);
			AUpvsetvaltype(pv, 3, AU_PVTYPE_LONG);
			l = blockAlign;
			AUpvsetval(pv, 3, &l);

			track->f.compressionParams = pv;
		}
		break;

		case WAVE_FORMAT_DVI_ADPCM:
		{
			uint16_t bitsPerSample, extraByteCount, samplesPerBlock;

			readU16(&bitsPerSample);
			readU16(&extraByteCount);
			readU16(&samplesPerBlock);

			if (bitsPerSample != 4)
			{
				_af_error(AF_BAD_NOT_IMPLEMENTED,
					"IMA ADPCM compression supports only 4 bits per sample");
			}

			int bytesPerBlock = (samplesPerBlock + 14) / 8 * 4 * channelCount;
			if (bytesPerBlock > blockAlign || (samplesPerBlock % 8) != 1)
			{
				_af_error(AF_BAD_CODEC_CONFIG,
					"Invalid samples per block for IMA ADPCM compression");
			}

			track->f.sampleWidth = 16;
			track->f.sampleFormat = AF_SAMPFMT_TWOSCOMP;
			track->f.compressionType = AF_COMPRESSION_IMA;
			track->f.byteOrder = _AF_BYTEORDER_NATIVE;

			/* Create the parameter list. */
			long l;
			AUpvlist pv = AUpvnew(2);
			AUpvsetparam(pv, 0, _AF_FRAMES_PER_BLOCK);
			AUpvsetvaltype(pv, 0, AU_PVTYPE_LONG);
			l = samplesPerBlock;
			AUpvsetval(pv, 0, &l);

			AUpvsetparam(pv, 1, _AF_BLOCK_SIZE);
			AUpvsetvaltype(pv, 1, AU_PVTYPE_LONG);
			l = blockAlign;
			AUpvsetval(pv, 1, &l);

			track->f.compressionParams = pv;
		}
		break;

		case WAVE_FORMAT_EXTENSIBLE:
		{
			uint16_t bitsPerSample;
			readU16(&bitsPerSample);
			uint16_t extraByteCount;
			readU16(&extraByteCount);
			uint16_t reserved;
			readU16(&reserved);
			uint32_t channelMask;
			readU32(&channelMask);
			UUID subformat;
			readUUID(&subformat);
			if (subformat == _af_wave_guid_pcm)
			{
				track->f.sampleWidth = bitsPerSample;

				if (bitsPerSample == 0 || bitsPerSample > 32)
				{
					_af_error(AF_BAD_WIDTH,
						"bad sample width of %d bits",
						bitsPerSample);
					return AF_FAIL;
				}

				// Use valid bits per sample if bytes per sample is the same.
				if (reserved <= bitsPerSample &&
					(reserved + 7) / 8 == (bitsPerSample + 7) / 8)
					track->f.sampleWidth = reserved;

				if (bitsPerSample <= 8)
					track->f.sampleFormat = AF_SAMPFMT_UNSIGNED;
				else
					track->f.sampleFormat = AF_SAMPFMT_TWOSCOMP;
			}
			else if (subformat == _af_wave_guid_ieee_float)
			{
				if (bitsPerSample == 64)
				{
					track->f.sampleWidth = 64;
					track->f.sampleFormat = AF_SAMPFMT_DOUBLE;
				}
				else
				{
					track->f.sampleWidth = 32;
					track->f.sampleFormat = AF_SAMPFMT_FLOAT;
				}
			}
			else if (subformat == _af_wave_guid_alaw ||
				subformat == _af_wave_guid_ulaw)
			{
				track->f.compressionType = subformat == _af_wave_guid_alaw ?
					AF_COMPRESSION_G711_ALAW : AF_COMPRESSION_G711_ULAW;
				track->f.sampleWidth = 16;
				track->f.sampleFormat = AF_SAMPFMT_TWOSCOMP;
				track->f.byteOrder = _AF_BYTEORDER_NATIVE;
			}
			else
			{
				_af_error(AF_BAD_NOT_IMPLEMENTED, "WAVE extensible data format %s is not currently supported", subformat.name().c_str());
				return AF_FAIL;
			}
		}
		break;

		case WAVE_FORMAT_YAMAHA_ADPCM:
		case WAVE_FORMAT_OKI_ADPCM:
		case WAVE_FORMAT_CREATIVE_ADPCM:
		case IBM_FORMAT_ADPCM:
			_af_error(AF_BAD_NOT_IMPLEMENTED, "WAVE ADPCM data format 0x%x is not currently supported", formatTag);
			return AF_FAIL;
			break;

		case WAVE_FORMAT_MPEG:
			_af_error(AF_BAD_NOT_IMPLEMENTED, "WAVE MPEG data format is not supported");
			return AF_FAIL;
			break;

		case WAVE_FORMAT_MPEGLAYER3:
			_af_error(AF_BAD_NOT_IMPLEMENTED, "WAVE MPEG layer 3 data format is not supported");
			return AF_FAIL;
			break;

		default:
			_af_error(AF_BAD_NOT_IMPLEMENTED, "WAVE file data format 0x%x not currently supported != 0xfffe ? %d, != EXTENSIBLE? %d", formatTag, formatTag != 0xfffe, formatTag != WAVE_FORMAT_EXTENSIBLE);
			return AF_FAIL;
			break;
	}

	_af_set_sample_format(&track->f, track->f.sampleFormat, track->f.sampleWidth);

	return AF_SUCCEED;
}
コード例 #26
0
Result_t
ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::OpenRead()
{
  if ( ! m_Root.ParseString(m_XMLDoc.c_str()) )
    return RESULT_FORMAT;

  m_TDesc.EncodingName = "UTF-8"; // the XML parser demands UTF-8
  m_TDesc.ResourceList.clear();
  m_TDesc.ContainerDuration = 0;
  const XMLNamespace* ns = m_Root.Namespace();

  if ( ns == 0 )
    {
      DefaultLogSink(). Warn("Document has no namespace name, assuming %s\n", c_dcst_namespace_name);
      m_TDesc.NamespaceName = c_dcst_namespace_name;
    }
  else
    {
      m_TDesc.NamespaceName = ns->Name();
    }

  UUID DocID;
  if ( ! get_UUID_from_child_element("Id", &m_Root, DocID) )
    {
      DefaultLogSink(). Error("Id element missing from input document\n");
      return RESULT_FORMAT;
    }

  memcpy(m_TDesc.AssetID, DocID.Value(), DocID.Size());
  XMLElement* EditRate = m_Root.GetChildWithName("EditRate");

  if ( EditRate == 0 )
    {
      DefaultLogSink(). Error("EditRate element missing from input document\n");
      return RESULT_FORMAT;
    }

  m_TDesc.EditRate = decode_rational(EditRate->GetBody().c_str());

  if ( m_TDesc.EditRate != EditRate_23_98
       && m_TDesc.EditRate != EditRate_24
       && m_TDesc.EditRate != EditRate_25
       && m_TDesc.EditRate != EditRate_30
       && m_TDesc.EditRate != EditRate_48
       && m_TDesc.EditRate != EditRate_50
       && m_TDesc.EditRate != EditRate_60 )
    {
      DefaultLogSink(). Error("Unexpected EditRate: %d/%d\n",
			      m_TDesc.EditRate.Numerator, m_TDesc.EditRate.Denominator);
      return RESULT_FORMAT;
    }

  // list of fonts
  ElementList FontList;
  m_Root.GetChildrenWithName("LoadFont", FontList);

  for ( Elem_i i = FontList.begin(); i != FontList.end(); i++ )
    {
      UUID AssetID;
      if ( ! get_UUID_from_element(*i, AssetID) )
	{
	  DefaultLogSink(). Error("LoadFont element does not contain a urn:uuid value as expected.\n");
	  return RESULT_FORMAT;
	}

      TimedTextResourceDescriptor TmpResource;
      memcpy(TmpResource.ResourceID, AssetID.Value(), UUIDlen);
      TmpResource.Type = MT_OPENTYPE;
      m_TDesc.ResourceList.push_back(TmpResource);
      m_ResourceTypes.insert(ResourceTypeMap_t::value_type(UUID(TmpResource.ResourceID), MT_OPENTYPE));
    }

  // list of images
  ElementList ImageList;
  m_Root.GetChildrenWithName("Image", ImageList);
  std::set<Kumu::UUID> visited_items;

  for ( Elem_i i = ImageList.begin(); i != ImageList.end(); i++ )
    {
      UUID AssetID;
      if ( ! get_UUID_from_element(*i, AssetID) )
	{
	  DefaultLogSink(). Error("Image element does not contain a urn:uuid value as expected.\n");
	  return RESULT_FORMAT;
	}

      if ( visited_items.find(AssetID) == visited_items.end() )
	{
	  TimedTextResourceDescriptor TmpResource;
	  memcpy(TmpResource.ResourceID, AssetID.Value(), UUIDlen);
	  TmpResource.Type = MT_PNG;
	  m_TDesc.ResourceList.push_back(TmpResource);
	  m_ResourceTypes.insert(ResourceTypeMap_t::value_type(UUID(TmpResource.ResourceID), MT_PNG));
	  visited_items.insert(AssetID);
	}
    }

  // Calculate the timeline duration.
  // This is a little ugly because the last element in the file is not necessarily
  // the last instance to be displayed, e.g., element n and element n-1 may have the
  // same start time but n-1 may have a greater duration making it the last to be seen.
  // We must scan the list to accumulate the latest TimeOut value.
  ElementList InstanceList;
  ElementList::const_iterator ei;
  ui32_t end_count = 0;
  
  m_Root.GetChildrenWithName("Subtitle", InstanceList);

  if ( InstanceList.empty() )
    {
      DefaultLogSink(). Error("XML document contains no Subtitle elements.\n");
      return RESULT_FORMAT;
    }

  // assumes edit rate is constrained above
  ui32_t TCFrameRate = ( m_TDesc.EditRate == EditRate_23_98  ) ? 24 : m_TDesc.EditRate.Numerator;

  S12MTimecode beginTC;
  beginTC.SetFPS(TCFrameRate);
  XMLElement* StartTime = m_Root.GetChildWithName("StartTime");

  if ( StartTime != 0 )
    beginTC.DecodeString(StartTime->GetBody());

  for ( ei = InstanceList.begin(); ei != InstanceList.end(); ei++ )
    {
      S12MTimecode tmpTC((*ei)->GetAttrWithName("TimeOut"), TCFrameRate);
      if ( end_count < tmpTC.GetFrames() )
	end_count = tmpTC.GetFrames();
    }

  if ( end_count <= beginTC.GetFrames() )
    {
      DefaultLogSink(). Error("Timed Text file has zero-length timeline.\n");
      return RESULT_FORMAT;
    }

  m_TDesc.ContainerDuration = end_count - beginTC.GetFrames();

  return RESULT_OK;
}
コード例 #27
0
ファイル: state.cpp プロジェクト: aelovikov/mesos
Try<RunState> RunState::recover(
    const string& rootDir,
    const SlaveID& slaveId,
    const FrameworkID& frameworkId,
    const ExecutorID& executorId,
    const UUID& uuid,
    bool strict)
{
  RunState state;
  state.id = uuid;
  string message;

  // Find the tasks.
  const Try<list<string> >& tasks = os::glob(strings::format(
      paths::TASK_PATH,
      rootDir,
      slaveId,
      frameworkId,
      executorId,
      uuid.toString(),
      "*").get());

  if (tasks.isError()) {
    return Error("Failed to find tasks for executor run " + uuid.toString() +
                 ": " + tasks.error());
  }

  // Recover tasks.
  foreach (const string& path, tasks.get()) {
    TaskID taskId;
    taskId.set_value(os::basename(path).get());

    const Try<TaskState>& task = TaskState::recover(
        rootDir, slaveId, frameworkId, executorId, uuid, taskId, strict);

    if (task.isError()) {
      return Error(
          "Failed to recover task " + taskId.value() + ": " + task.error());
    }

    state.tasks[taskId] = task.get();
    state.errors += task.get().errors;
  }

  // Read the forked pid.
  string path = paths::getForkedPidPath(
      rootDir, slaveId, frameworkId, executorId, uuid);
  if (!os::exists(path)) {
    // This could happen if the slave died before the isolator
    // checkpointed the forked pid.
    LOG(WARNING) << "Failed to find executor forked pid file '" << path << "'";
    return state;
  }

  Try<string> pid = os::read(path);

  if (pid.isError()) {
    message = "Failed to read executor forked pid from '" + path +
              "': " + pid.error();

    if (strict) {
      return Error(message);
    } else {
      LOG(WARNING) << message;
      state.errors++;
      return state;
    }
  }

  if (pid.get().empty()) {
    // This could happen if the slave died after opening the file for
    // writing but before it checkpointed anything.
    LOG(WARNING) << "Found empty executor forked pid file '" << path << "'";
    return state;
  }

  Try<pid_t> forkedPid = numify<pid_t>(pid.get());
  if (forkedPid.isError()) {
    return Error("Failed to parse forked pid " + pid.get() +
                 ": " + forkedPid.error());
  }

  state.forkedPid = forkedPid.get();

  // Read the libprocess pid.
  path = paths::getLibprocessPidPath(
      rootDir, slaveId, frameworkId, executorId, uuid);

  if (!os::exists(path)) {
    // This could happen if the slave died before the executor
    // registered with the slave.
    LOG(WARNING)
      << "Failed to find executor libprocess pid file '" << path << "'";
    return state;
  }

  pid = os::read(path);

  if (pid.isError()) {
    message = "Failed to read executor libprocess pid from '" + path +
              "': " + pid.error();

    if (strict) {
      return Error(message);
    } else {
      LOG(WARNING) << message;
      state.errors++;
      return state;
    }
  }

  if (pid.get().empty()) {
    // This could happen if the slave died after opening the file for
    // writing but before it checkpointed anything.
    LOG(WARNING) << "Found empty executor libprocess pid file '" << path << "'";
    return state;
  }

  state.libprocessPid = process::UPID(pid.get());

  // See if the sentinel file exists.
  path = paths::getExecutorSentinelPath(
      rootDir, slaveId, frameworkId, executorId, uuid);

  state.completed = os::exists(path);

  return state;
}
コード例 #28
0
FileSpec
ModuleCache::GetModuleDirectory (const FileSpec &root_dir_spec, const UUID &uuid)
{
    const auto modules_dir_spec = JoinPath (root_dir_spec, kModulesSubdir);
    return JoinPath (modules_dir_spec, uuid.GetAsString ().c_str ());
}
コード例 #29
0
ble_error_t BlueNRGGattClient::launchServiceDiscovery(Gap::Handle_t                               connectionHandle,
                                                      ServiceDiscovery::ServiceCallback_t         sc,
                                                      ServiceDiscovery::CharacteristicCallback_t  cc,
                                                      const UUID                                 &matchingServiceUUID,
                                                      const UUID                                 &matchingCharacteristicUUIDIn)
{
  PRINTF("launchServiceDiscovery\n\r");
  
  tBleStatus ret;
  uint8_t uuid_type = UUID_TYPE_16;
  uint8_t short_uuid[2];
  uint8_t *uuid = NULL;
  unsigned j;
  
  _connectionHandle = connectionHandle;
  serviceDiscoveryCallback = sc;
  characteristicDiscoveryCallback = cc;
  _matchingServiceUUID = matchingServiceUUID;
  _matchingCharacteristicUUIDIn = matchingCharacteristicUUIDIn;

  //reset services
  _numServices = 0;
  _numChars = 0;
  _servIndex = 0;
  for(j = 0; j < BLE_TOTAL_DISCOVERED_SERVICES; j++) {
    discoveredService[j].setup(BLE_UUID_UNKNOWN, GattAttribute::INVALID_HANDLE, GattAttribute::INVALID_HANDLE);
  }
  
  if(matchingServiceUUID == BLE_UUID_UNKNOWN) {
    
    // Wildcard: search for all services
    ret = aci_gatt_disc_all_prim_services((uint16_t)connectionHandle);
    
  } else {
  
    uint8_t type = matchingServiceUUID.shortOrLong();
    //PRINTF("AddService(): Type:%d\n\r", type);
    
    if(type == UUID::UUID_TYPE_SHORT) {
      STORE_LE_16(short_uuid, matchingServiceUUID.getShortUUID());
      
      PRINTF("launchServiceDiscovery short_uuid=0x");
      for(j = 0; j < 2; j++) {
        PRINTF("%02X", short_uuid[j]);
      }
      PRINTF("\n\r");
      
      
      uuid_type = UUID_TYPE_16;
      uuid = short_uuid;
      
    } else if(type==UUID::UUID_TYPE_LONG) {

      uuid_type = UUID_TYPE_128;
      uuid = (unsigned char*)matchingServiceUUID.getBaseUUID();
      
      /*
      PRINTF("launchServiceDiscovery base_uuid=0x");
      for(j = 0; j < 16; j++) {
        PRINTF("%02X", uuid[j]);
      }
      PRINTF("\n\r");
      */
    }
    
    // search for specific service by UUID
    ret = aci_gatt_disc_prim_service_by_uuid((uint16_t)connectionHandle, uuid_type, uuid);
    //ret = aci_gatt_disc_all_prim_services((uint16_t)connectionHandle);
  }
    
  if(ret == BLE_STATUS_SUCCESS) {
    _currentState = GATT_SERVICE_DISCOVERY;
  }
  
  PRINTF("launchServiceDiscovery ret=%d\n\r", ret);
  
  return BLE_ERROR_NONE;
}
コード例 #30
0
void CraqObjectSegmentation::beginCraqLookup(const UUID& obj_id, OSegLookupTraceToken* traceToken)
{
    --mOSegQueueLen;
    if (mStopping)
    {
        delete traceToken;
        return;
    }

    traceToken->stamp(OSegLookupTraceToken::OSEG_TRACE_CRAQ_LOOKUP_BEGIN);

    UUID tmper = obj_id;
    InTransitMap::const_iterator iter = mInTransitOrLookup.find(tmper);

    if (iter == mInTransitOrLookup.end()) //means that the object isn't already being looked up and the object isn't already in transit
    {
        //Duration beginCraqLookupNotAlreadyLookingUpDur = Time::local() - Time::epoch();
        //traceToken->craqLookupNotAlreadyLookingUpBegin  = beginCraqLookupNotAlreadyLookingUpDur.toMicroseconds();
        traceToken->stamp(OSegLookupTraceToken::OSEG_TRACE_CRAQ_LOOKUP_NOT_ALREADY_LOOKING_UP_BEGIN);

        //if object is not in transit, lookup its location in the dht.  returns -1 if object doesn't exist.
        //add the mapping of a craqData Key to a uuid.

        ++numCraqLookups;

        std::string indexer = "";
        indexer.append(1,myUniquePrefixKey);
        indexer.append(tmper.rawHexData());

        CraqDataSetGet cdSetGet (indexer,CraqEntry::null(),false,CraqDataSetGet::GET); //bftm modified

        mapDataKeyToUUID[indexer] = tmper; //changed here.


        CONTEXT_SPACETRACE(objectSegmentationCraqLookupRequest,
                           obj_id,
                           mContext->id());

        ++numLookingUpDebug;

        //puts object in transit or lookup.
        //Duration timerDur =  Time::local() - Time::epoch();

        TransLookup tmpTransLookup;
        tmpTransLookup.sID = CraqEntry::null();  //means that we're performing a lookup, rather than a migrate.
        //tmpTransLookup.timeAdmitted = (int)timerDur.toMilliseconds();
        tmpTransLookup.timeAdmitted = 0;

        mInTransitOrLookup[tmper] = tmpTransLookup; //just says that we are performing a lookup on the object

        traceToken->stamp(OSegLookupTraceToken::OSEG_TRACE_CRAQ_LOOKUP_END);
        traceToken->stamp(OSegLookupTraceToken::OSEG_TRACE_CRAQ_LOOKUP_NOT_ALREADY_LOOKING_UP_END);

        if ((numCraqLookups %2) == 0)
            craqDhtGet1.get(cdSetGet,traceToken); //calling the craqDht to do a get
        else
            craqDhtGet2.get(cdSetGet,traceToken); //calling the craqDht to do a get.
    }
    else
    {
        ++numAlreadyLookingUp;
        traceToken->stamp(OSegLookupTraceToken::OSEG_TRACE_CRAQ_LOOKUP_END);
        CONTEXT_SPACETRACE(osegCumulativeResponse, traceToken);
        delete traceToken;
    }
}