void AbstractGeneratorConfig::computeLinearScalePartitioning(const string& key)
{
    I64u cardinality = static_cast<I64u>(scalingFactor() * getInt("partitioning." + key + ".base-cardinality"));
    double chunkSize = cardinality / static_cast<double> (numberOfChunks());

    I64u genIDBegin = static_cast<ID> ((chunkSize * nodeID()) + 0.5);
    I64u genIDEnd = static_cast<ID> ((chunkSize * (nodeID() + 1) + 0.5));

    setString("generator." + key + ".sequence.base_cardinality", getString("partitioning." + key + ".base-cardinality"));
    setString("generator." + key + ".sequence.cardinality", toString(cardinality));
    setString("generator." + key + ".partition.begin", toString(genIDBegin));
    setString("generator." + key + ".partition.end", toString(genIDEnd));
}
//----------------------------------------------------------------------------------------
// GetNumChildren
//----------------------------------------------------------------------------------------
int32
CZPTasksTVHierarchyAdapter::GetNumChildren(const NodeID& node) const
{
	int32 retVal = 0;
	do
	{
		ZPTreeNodePtr< const ZPTasksTVNodeID> nodeID(node);
		ASSERT(nodeID != nil);
		if (nodeID == nil)
			break;

		//No child for Task node
		if( nodeID->GetNodeType() == eTVNodeTask )
			return retVal;

		InterfacePtr<const IZPTasksTVDataModel> selfModel( this, UseDefaultIID() );
		ASSERT(selfModel);

		//Return the number of task for current title
		if( nodeID->GetNodeType() == eTVNodeRoot )
		{
			const ZPTaskIDsList * taskList = selfModel->GetTaskIDList();
			if( taskList )
				return taskList->size();
			return 0;
		}

	} while(kFalse);
	
	return retVal;
}
Example #3
0
/* make this page contains block of for mallocID, with the list of blocks
 * ready to be allocated all set up.
 */
void
MemDesc::init(uval mallocid, uval nodeid)
{
    MemDescBits mdb;
    uval bSize;
    uval numBlocks;
    uval addr;

    if (mallocID() == mallocid && nodeID() == nodeid) {
	// already initialized to the right values
	return;
    }

    bSize     = AllocPool::MallocIDToSize(mallocid);
    numBlocks = ALLOC_PAGE_SIZE / bSize;
    addr      = getPage();

    tassert((bSize & (sizeof(DataChunk)-1)) == 0,
	    err_printf("size alignment not supported\n"));

    mdb.all(0);				// all fields zero by default
    mdb.mallocID(mallocid);
    mdb.nodeID(nodeid);

    BitBLock<MemDescBits>::init(mdb);

    /* freeCellOffset starts off pointing to first address of page */
    for (; numBlocks > 0; numBlocks--, addr += bSize) {
	((DataChunk *)addr)->next = (DataChunk *) (addr + bSize);
    }
    ((DataChunk *)(addr - bSize))->next = invalidChunk();
}
//----------------------------------------------------------------------------------------
// GetSelectedAd
//----------------------------------------------------------------------------------------
const IStringData *
CZMAdsPanelHelper::GetSelectedAd()const
{
	const IStringData *	toReturn = nil;
	do
	{
		IControlView * treeControlView = this->GetWidgetView( kZMUIAdsPanelLstAdsWidgetID );
		ASSERT( treeControlView );
		InterfacePtr<const ITreeViewController> tvController( treeControlView, UseDefaultIID());
		ASSERT( tvController );
		NodeIDList selectedNodes;
		tvController->GetSelectedItems( selectedNodes );
		if( selectedNodes.Length() == 1 )
		{
			ZMTreeNodePtr<ZMAdsTVNodeID> nodeID(selectedNodes[0]);
			if (nodeID != nil)
			{
				const PMString & theAdID = nodeID->GetID();//("55a7be8e-8c82-4a07-a467-f54497b50c10");
			//TODO: media porting
			///	toReturn = ZMDataHelper::GetAdByID( theAdID );
			}
		}
	}while(kFalse);

	return toReturn;
}
Example #5
0
spep::SPEP* spep::SPEP::initializeServer( spep::ConfigurationReader &configurationReader, std::vector<saml2::Handler*> handlers )
{
	spep::SPEP *spep = new spep::SPEP;

	spep->_mode = SPEP_MODE_SERVER;
	spep->_isStarted = false;

	spep->_logger = new saml2::Logger();

	for( std::vector<saml2::Handler*>::iterator handlerIterator = handlers.begin();
		handlerIterator != handlers.end();  ++handlerIterator )
	{
		spep->_logger->registerHandler( *handlerIterator );
	}

	saml2::LocalLogger localLogger(spep->_logger, "spep::SPEP");
	localLogger.debug() << "Beginning to initialize server-side SPEP components.";

	spep->_configuration = new ConfigurationImpl( configurationReader );
	spep->_spepConfigData = new SPEPConfigData( spep->_configuration->getSPEPConfigData() );

	int allowedTimeSkew = configurationReader.getIntegerValue( CONFIGURATION_ALLOWEDTIMESKEW );
	int metadataInterval = configurationReader.getIntegerValue( CONFIGURATION_METADATAINTERVAL );
	int attributeConsumingServiceIndex = configurationReader.getIntegerValue( CONFIGURATION_ATTRIBUTECONSUMINGSERVICEINDEX );
	int assertionConsumerServiceIndex = configurationReader.getIntegerValue( CONFIGURATION_ASSERTIONCONSUMERSERVICEINDEX );
	int authzCacheIndex = configurationReader.getIntegerValue( CONFIGURATION_AUTHZCACHEINDEX );
	int startupRetryInterval = configurationReader.getIntegerValue( CONFIGURATION_STARTUPRETRYINTERVAL );
	int sessionCacheInterval = configurationReader.getIntegerValue( CONFIGURATION_SESSIONCACHEINTERVAL );
	int sessionCacheTimeout = configurationReader.getIntegerValue( CONFIGURATION_SESSIONCACHETIMEOUT );
	std::string nodeID( configurationReader.getStringValue( CONFIGURATION_NODEIDENTIFIER ) );
	std::string caBundle( configurationReader.getStringValue( CONFIGURATION_CABUNDLE, std::string() ) );

	Decision defaultPolicyDecision( configurationReader.getStringValue( CONFIGURATION_DEFAULTPOLICYDECISION ) );

	std::string schemaPath( configurationReader.getStringValue( CONFIGURATION_SCHEMAPATH ) );
	std::wstring spepIdentifier( UnicodeStringConversion::toWString( configurationReader.getStringValue( CONFIGURATION_SPEPIDENTIFIER ) ) );
	std::wstring esoeIdentifier( UnicodeStringConversion::toWString( configurationReader.getStringValue( CONFIGURATION_ESOEIDENTIFIER ) ) );
	std::string metadataURL( configurationReader.getStringValue( CONFIGURATION_METADATAURL ) );

	spep->_identifierCache = new saml2::IdentifierCache();
	spep->_identifierGenerator = new saml2::IdentifierGenerator( spep->_identifierCache );
	spep->_samlValidator = new saml2::SAMLValidator( spep->_identifierCache, allowedTimeSkew );

	spep->_metadata = new MetadataImpl( spep->_logger, schemaPath, spepIdentifier, esoeIdentifier, metadataURL, caBundle, spep->_spepConfigData->getKeyResolver(), assertionConsumerServiceIndex, metadataInterval );

	spep->_soapUtil = new SOAPUtil( spep->_logger, schemaPath );

	spep->_wsClient = new WSClient( spep->_logger, caBundle, spep->_soapUtil );

	spep->_attributeProcessor = new AttributeProcessor( spep->_logger, spep->_metadata, spep->_spepConfigData->getKeyResolver(), spep->_identifierGenerator, spep->_wsClient, spep->_samlValidator, schemaPath, spep->_spepConfigData->getAttributeRenameMap() );
	spep->_sessionCache = new SessionCacheImpl( spep->_logger );
	spep->_sessionCacheThread = new SessionCacheThread( spep->_logger, spep->_sessionCache, sessionCacheTimeout, sessionCacheInterval );
	spep->_authnProcessor = new AuthnProcessor( spep->_logger, spep->_attributeProcessor, spep->_metadata, spep->_sessionCache, spep->_samlValidator, spep->_identifierGenerator, spep->_spepConfigData->getKeyResolver(), spepIdentifier, spep->_spepConfigData->getSSORedirect(), spep->_spepConfigData->getServiceHost(), schemaPath, attributeConsumingServiceIndex, assertionConsumerServiceIndex );
	spep->_sessionGroupCache = new SessionGroupCacheImpl( spep->_logger, defaultPolicyDecision );
	spep->_policyEnforcementProcessor = new PolicyEnforcementProcessor( spep->_logger, spep->_wsClient, spep->_sessionGroupCache, spep->_sessionCache, spep->_metadata, spep->_identifierGenerator, spep->_samlValidator, spep->_spepConfigData->getKeyResolver(), schemaPath );
	spep->_startupProcessor = new StartupProcessorImpl( spep->_logger, spep->_wsClient, spep->_metadata, spep->_spepConfigData->getKeyResolver(), spep->_identifierGenerator, spep->_samlValidator, schemaPath, spepIdentifier, spep->_spepConfigData->getIPAddresses(), nodeID, authzCacheIndex, startupRetryInterval );
	spep->_wsProcessor = new WSProcessor( spep->_logger, spep->_authnProcessor, spep->_policyEnforcementProcessor, spep->_soapUtil );

	return spep;
}
Example #6
0
std::string PyBoundObject::GetBindStr() const {
    //generate a nice bind string:
    char bind_str[128];
    snprintf(bind_str, sizeof(bind_str), "N=%u:%u", nodeID(), bindID());

    return(std::string(bind_str));
}
//----------------------------------------------------------------------------------------
// GetNthChild
//----------------------------------------------------------------------------------------
NodeID_rv
CZPTasksTVHierarchyAdapter::GetNthChild( const NodeID& node, const int32& nth) const
{
	do
	{
		ZPTreeNodePtr< const ZPTasksTVNodeID> nodeID(node);
		ASSERT(nodeID != nil);
		if (nodeID == nil)
			break;

		//No child for task node
		ASSERT( nodeID->GetNodeType() != eTVNodeTask );
		
		InterfacePtr<const IZPTasksTVDataModel> selfModel( this, UseDefaultIID() );
		ASSERT(selfModel);

		//Return nth task id
		//Commented check as we have only one type of node
		//if( nodeID->GetNodeType() == eTVNodeRoot )
		{
			const PMString * taskID = selfModel->GetNthTaskID( nth );
			ASSERT( taskID != nil );
			return ZPTasksTVNodeID::Create( eTVNodeTask, *taskID );
		}
	} while(kFalse);
	return kInvalidNodeID;
}
Example #8
0
void KMLNetOutput::createKML(const std::string& fileWithNodes, const std::string& kmlFileName){

	std::cout << "KML will be written to: " << kmlFileName << std::endl;
	int nbNodes = net_->getNbNodes();
	std::vector<FPType> xCoord(nbNodes, 0);
	std::vector<FPType> yCoord(nbNodes, 0);
	std::vector<int> nodeID(nbNodes, 0);
	
	readCoord(fileWithNodes, xCoord, yCoord, nodeID);

	FileWriter writeKml(kmlFileName);
	writeKml.writeLine(createKmlHeader());
	
	for (StarLink* link = net_->beginOnlyLink(); link != NULL; link = net_->getNextOnlyLink()) {
		if (shouldCreatePlacemark(link)) {
			int tail = link->getNodeFromIndex();
			int head = link->getNodeToIndex();
			FPType x1 = xCoord[tail];
			FPType y1 = yCoord[tail];
			FPType x2 = xCoord[head];
			FPType y2 = yCoord[head];
			if (x1 == 0 && y1 == 0) std::cout << "Missing node coordinate: " << link->getNodeFrom() << 
								" link: " << link->toString() << std::endl; 
			if (x2 == 0 && y2 == 0) std::cout << "Missing node coordinate: " << link->getNodeTo() << 
								" link: " << link->toString() << std::endl;
			if (x1 != 0 && y1 != 0 && x2 != 0 && y2 != 0) 
				writeKml.writeLine(createPlacemark(x1, y1, x2, y2, link)); 
		}
	}

	writeKml.writeLine(createKmlFooter());
};
Example #9
0
//!
//! Processes the node's input data to generate the node's output table.
//!
void Model2SceneNode::processScene()
{
	// load the input vtk parameter 
	VTKTableParameter * inputParameter = dynamic_cast<VTKTableParameter*>(getParameter(m_inputVTKTableParameterName));
	if (!inputParameter || !inputParameter->isConnected())
		return;

	// get the source parameter (output of source node) connected to the input parameter
	VTKTableParameter * sourceParameter = dynamic_cast<VTKTableParameter*>(inputParameter->getConnectedParameter());

	inputParameter->setVTKTable(sourceParameter->getVTKTable());

	vtkTable * xyzTable = inputParameter->getVTKTable();

	if (!m_sceneNode)
		createSceneNode();


	if (!m_entity || !xyzTable || !m_sceneNode)
		return;

	//Get columns named "NodeID", "X", "Y" and "Z"
	vtkIdTypeArray *colNodeId = dynamic_cast<vtkIdTypeArray*>(xyzTable->GetColumnByName("NodeId"));
	vtkDoubleArray *colX = dynamic_cast<vtkDoubleArray*>(xyzTable->GetColumnByName("X"));
	vtkDoubleArray *colY = dynamic_cast<vtkDoubleArray*>(xyzTable->GetColumnByName("Y"));
	vtkDoubleArray *colZ = dynamic_cast<vtkDoubleArray*>(xyzTable->GetColumnByName("Z"));

	destroyAllAttachedMovableObjects(m_sceneNode);
	destroyAllChildren(m_sceneNode);

	Ogre::String idPrefix(QString(m_name + ":").toStdString());

	Ogre::SceneManager *sceneManager = OgreManager::getSceneManager();

	for (int i=0; i<xyzTable->GetNumberOfRows(); i++)
	{
		int colIDValue = colNodeId->GetValue(i);
		Ogre::String nodeID(idPrefix + Ogre::StringConverter::toString(colIDValue));

		// create new scene node for each item
		Ogre::SceneNode *sceneItem = sceneManager->createSceneNode(nodeID);

		// create new entity for each item
		Ogre::Entity *entityItem = m_entity->clone(nodeID);
		
		sceneItem->attachObject(entityItem);

		double x = colX->GetValue(i);
		double y = colY->GetValue(i);
		double z = colZ->GetValue(i);
		sceneItem->setPosition(Ogre::Real(x), Ogre::Real(y), Ogre::Real(z));
		sceneItem->setScale(m_size);
		m_sceneNode->addChild(sceneItem);
		
	}
}
Example #10
0
int DSRCCar :: ChannelPollingMod4( )
{
	int mod = nodeID() % 4;
	for(int ch = CH_NORMAL1+mod; ch <= CH_NORMAL4+mod; ch++){
		if(ni1 . isIdle(ch%4) ){
			return ch%4;
		}
	} 
	return -1;
}
//----------------------------------------------------------------------------------------
// GetParentNode
//----------------------------------------------------------------------------------------
NodeID_rv
CZPTasksTVHierarchyAdapter::GetParentNode(const NodeID& node) const
{
	do
	{
		ZPTreeNodePtr<const ZPTasksTVNodeID> nodeID(node);
		ASSERT(nodeID != nil);
		if (nodeID == nil)
			break;
		
		if( nodeID->GetNodeType() == eTVNodeRoot )			// The root has no parent: this will be a general result
			break;
		else if ( nodeID->GetNodeType() == eTVNodeTask )	// Task node parent is root node
			return ZPTasksTVNodeID::Create( eTVNodeRoot );
	} while(kFalse);
	
	return kInvalidNodeID;
}
Example #12
0
int DSRCCar :: ChannelWarnPollingMod2()
{
	switch( nodeID() %2 ){
		case 0:
			if(ni1 . isIdle( CH_WARNG1 ) )
				return CH_WARNG1;
			else if(ni1 . isIdle( CH_WARNG2 ) )
				return CH_WARNG2;
			break;
		case 1:
			if(ni1 . isIdle( CH_WARNG2 ) )
				return CH_WARNG2;
			else if(ni1 . isIdle( CH_WARNG1 ) )
				return CH_WARNG1;
			break;

	}
	return ChannelPollingMod4();
}
void AbstractGeneratorConfig::computeFixedPartitioning(const string& key)
{
    ID cardinality = fromString<ID> (getString("partitioning." + key + ".cardinality"));

    ID genIDBegin, genIDEnd;

    // chunk 0 is responsible for dumping all data
    if (nodeID() == 0)
    {
        genIDBegin = 0;
        genIDEnd = cardinality;
    }
    else
    {
        genIDBegin = cardinality;
        genIDEnd = cardinality;
    }

    setString("generator." + key + ".sequence.cardinality", toString(cardinality));
    setString("generator." + key + ".partition.begin", toString(genIDBegin));
    setString("generator." + key + ".partition.end", toString(genIDEnd));
}
Example #14
0
bool DSRCCar::BrLocation()
{
	int channel = -1;
	if( AccLevel() == BRAKE_EMERG || backBulb() == BULB_RED){
		if( ChChMode() == CHCH_POLL ){
			channel = ChannelWarnPolling();
		}else if( ChChMode() == CHCH_ID_POLL ){
			channel = ChannelWarnPollingMod2(); 
		}
	}else{
		if( ChChMode() == CHCH_POLL ){
			channel = ChannelPolling();
		}else if( ChChMode() == CHCH_ID_POLL ){
			channel = ChannelPollingMod4(); 
		}
	}

	if( channel == -1 )	return false;
	InfoPacket *p = new InfoPacket(  realX(), realY() , nodeID(), realVelocity() );

//	debug("DSRCCar BrLocation::  (%e,%e)",p->X(),p->Y());

	return ni1 . BrSend( p , channel);
}
Example #15
0
bool RegisterNodeMsgEx::processIncoming(struct sockaddr_in* fromAddr, Socket* sock,
   char* respBuf, size_t bufLen, HighResolutionStats* stats)
{
   LogContext log("RegisterNodeMsg incoming");

   std::string peer = fromAddr ? Socket::ipaddrToStr(&fromAddr->sin_addr) : sock->getPeername();
   LOG_DEBUG_CONTEXT(log, Log_DEBUG, std::string("Received a RegisterNodeMsg from: ") + peer);

   App* app = Program::getApp();
   NodeType nodeType = getNodeType();
   std::string nodeID(getNodeID() );

   NicAddressList nicList;
   BitStore nodeFeatureFlags;
   Node* node;

   uint16_t newNodeNumID;
   bool isNodeNew;


   LOG_DEBUG_CONTEXT(log, Log_SPAM,
      "Type: " + Node::nodeTypeToStr(nodeType) + "; "
      "NodeID: " + nodeID + "; "
      "NodeNumID: " + StringTk::uintToStr(getNodeNumID() ) );


   // check for empty nodeID; (sanity check, should never fail)

   if(unlikely(nodeID.empty() ) )
   {
      log.log(Log_WARNING, "Rejecting registration of node with empty string ID "
         "from: " + peer + "; "
         "type: " + Node::nodeTypeToStr(nodeType) );

      return false;
   }


   // get the corresponding node store for this node type

   NodeStoreServers* servers = app->getServerStoreFromType(nodeType);
   if(unlikely(!servers) )
   {
      log.logErr("Invalid node type for registration: " + Node::nodeTypeToStr(nodeType) + "; "
         "from: " + peer);

      newNodeNumID = 0;
      goto send_response;
   }

   // check if adding of new servers is allowed

   if(!checkNewServerAllowed(servers, getNodeNumID(), nodeType) )
   { // this is a new server and adding was disabled
      log.log(Log_WARNING, "Registration of new servers disabled. Rejecting node: " +
         nodeID + " (Type: " + Node::nodeTypeToStr(nodeType) + ")");

      newNodeNumID = 0;
      goto send_response;
   }

   // construct node

   parseNicList(&nicList);

   node = constructNode(nodeID, getNodeNumID(), getPortUDP(), getPortTCP(), nicList);

   node->setNodeType(getNodeType() );
   node->setFhgfsVersion(getFhgfsVersion() );

   parseNodeFeatureFlags(&nodeFeatureFlags);

   node->setFeatureFlags(&nodeFeatureFlags);

   // add node to store (or update it)

   isNodeNew = servers->addOrUpdateNodeEx(&node, &newNodeNumID);

   if(!newNodeNumID)
   { // unable to add node to store
      log.log(Log_WARNING,
         "Unable to add node with given numeric ID: " + StringTk::uintToStr(getNodeNumID() ) + "; "
         "string ID: " + getNodeID() + "; "
         "Type: " + Node::nodeTypeToStr(nodeType) );

      goto send_response;
   }

   /* note on capacity pools:
      we may not add new nodes to capacity pools here yet, because at this point the registered
      node is not ready to receive messages yet. so we will add it to capacity pools later when we
      receive its first heartbeat msg. */

   processIncomingRoot(getRootNumID(), nodeType);

   if(isNodeNew)
   { // this node is new
      processNewNode(nodeID, newNodeNumID, nodeType, getFhgfsVersion(), &nicList, peer);
   }

   // send response
send_response:

   RegisterNodeRespMsg respMsg(newNodeNumID);
   respMsg.serialize(respBuf, bufLen);
   sock->sendto(respBuf, respMsg.getMsgLength(), 0,
      (struct sockaddr*)fromAddr, sizeof(struct sockaddr_in) );

   return true;
}
Example #16
0
PyResult PyBoundObject::Call(const std::string &method, PyCallArgs &args) {
    sLog.Debug("Bound Object","NodeID: %u BindID: %u calling %s in service manager '%s'", nodeID(), bindID(), method.c_str(), GetBoundObjectClassStr().c_str());
    args.Dump(SERVICE__CALL_TRACE);

    return(PyCallable::Call(method, args));
}
Example #17
0
/**
 * Note: unlocked, so caller must hold lock.
 *
 * @param node belongs to the store after calling this method; this method will set (*node=NULL);
 * so do not free it and don't use it any more afterwards (reference it from this store if you need
 * it)
 * @param outNodeNumID will be set to the the node's numeric ID if no error occurred, 0 otherwise
 * (may be NULL if caller doesn't care).
 * @return true if the node was not in the active group yet and has been added to the active
 * group (i.e. new node), false otherwise
 */
bool NodeStoreServers::addOrUpdateNodeUnlocked(Node** node, uint16_t* outNodeNumID)
{
   uint16_t nodeNumID = (*node)->getNumID();
   std::string nodeID( (*node)->getID() );

   // check if given node is localNode

   if(localNode && (nodeNumID == localNode->getNumID() ) )
   { // we don't allow to update local node this way (would lead to problems during sync etc.)
      delete(*node);
      *node = NULL;

      SAFE_ASSIGN(outNodeNumID, nodeNumID);
      return false;
   }

   // check if numID is given

   if(!nodeNumID)
   { // no numID yet => generate it
      nodeNumID = generateNodeNumID(*node);
      if(unlikely(!nodeNumID) )
      { // no numID available
         LogContext(__func__).logErr(
            std::string("Unable to add new node, ran out of numeric IDs. NodeID: ") + nodeID);

         delete(*node);
         *node = NULL;

         SAFE_ASSIGN(outNodeNumID, nodeNumID);
         return false;
      }

      (*node)->setNumID(nodeNumID); // assign new numeric ID
   }


   // check if this is a new node or an update of an existing node

   /* note: the activeNodes.find(nodeNumID) below needs to be done even if node->getNumID() was
      initially 0, because generateNodeNumID() might have found that the node already had a numID
      and just didn't know about it (e.g. when it sent a registration retry message). */

   NodeMapIter iter = activeNodes.find(nodeNumID);
   bool nodeWasActive = (iter != activeNodes.end() );

   if(nodeWasActive)
   { // node was in the active store already => update it
      NodeReferencer* nodeRefer = iter->second;
      Node* nodeNonRef = nodeRefer->getReferencedObject();
      NicAddressList nicList( (*node)->getNicList() );

      if(unlikely(nodeNonRef->getID() != (*node)->getID() ) )
      { // bad: numeric ID collision for two different node string IDs
         LogContext(__func__).logErr(
            std::string("Numeric ID collision for two different string IDs: ") +
            nodeID + " / " + nodeNonRef->getID() );

         nodeNumID = 0; // set to invalid ID, so caller hopefully checks outNodeNumID
      }
      else
      { // update node
         nodeNonRef->updateLastHeartbeatT();
         nodeNonRef->setFhgfsVersion( (*node)->getFhgfsVersion() );
         nodeNonRef->updateInterfaces( (*node)->getPortUDP(), (*node)->getPortTCP(), nicList);
      }

      delete(*node);
   }
   else
   { // node wasn't in active store yet => insert it
      activeNodes.insert(NodeMapVal(nodeNumID, new NodeReferencer(*node) ) );

      #ifdef FHGFS_DEBUG
      // check whether node type and store type differ
      if( ( (*node)->getNodeType() != NODETYPE_Invalid) &&
          ( (*node)->getNodeType() != storeType) )
      {
         LogContext(__func__).logErr("Node type and store type differ. "
            "Node: " + (*node)->getNodeIDWithTypeStr() + "; "
            "Store: " + Node::nodeTypeToStr(storeType) );
      }
      #endif // FHGFS_DEBUG

      (*node)->setNodeType(storeType);
      (*node)->getConnPool()->setChannelDirect(channelsDirectDefault);

      newNodeCond.broadcast();
   }


   *node = NULL;
   SAFE_ASSIGN(outNodeNumID, nodeNumID);

   return !nodeWasActive;
}
Example #18
0
void ValueRecovery::dumpInContext(PrintStream& out, DumpContext* context) const
{
    switch (technique()) {
    case InGPR:
        out.print(gpr());
        return;
    case UnboxedInt32InGPR:
        out.print("int32(", gpr(), ")");
        return;
    case UnboxedInt52InGPR:
        out.print("int52(", gpr(), ")");
        return;
    case UnboxedStrictInt52InGPR:
        out.print("strictInt52(", gpr(), ")");
        return;
    case UnboxedBooleanInGPR:
        out.print("bool(", gpr(), ")");
        return;
    case UnboxedCellInGPR:
        out.print("cell(", gpr(), ")");
        return;
    case InFPR:
        out.print(fpr());
        return;
#if USE(JSVALUE32_64)
    case InPair:
        out.print("pair(", tagGPR(), ", ", payloadGPR(), ")");
        return;
#endif
    case DisplacedInJSStack:
        out.print("*", virtualRegister());
        return;
    case Int32DisplacedInJSStack:
        out.print("*int32(", virtualRegister(), ")");
        return;
    case Int52DisplacedInJSStack:
        out.print("*int52(", virtualRegister(), ")");
        return;
    case StrictInt52DisplacedInJSStack:
        out.print("*strictInt52(", virtualRegister(), ")");
        return;
    case DoubleDisplacedInJSStack:
        out.print("*double(", virtualRegister(), ")");
        return;
    case CellDisplacedInJSStack:
        out.print("*cell(", virtualRegister(), ")");
        return;
    case BooleanDisplacedInJSStack:
        out.print("*bool(", virtualRegister(), ")");
        return;
    case DirectArgumentsThatWereNotCreated:
        out.print("DirectArguments(", nodeID(), ")");
        return;
    case ClonedArgumentsThatWereNotCreated:
        out.print("ClonedArguments(", nodeID(), ")");
        return;
    case Constant:
        out.print("[", inContext(constant(), context), "]");
        return;
    case DontKnow:
        out.printf("!");
        return;
    }
    RELEASE_ASSERT_NOT_REACHED();
}
Example #19
0
bool HeartbeatMsgEx::processIncoming(struct sockaddr_in* fromAddr, Socket* sock,
   char* respBuf, size_t bufLen, HighResolutionStats* stats)
{
   LogContext log("Heartbeat incoming");

   std::string peer = fromAddr ? Socket::ipaddrToStr(&fromAddr->sin_addr) : sock->getPeername();
   //LOG_DEBUG_CONTEXT(log, Log_DEBUG, std::string("Received a HeartbeatMsg from: ") + peer);

   App* app = Program::getApp();
   NodeCapacityPools* metaCapacityPools = app->getMetaCapacityPools();
   HeartbeatManager* heartbeatMgr = app->getHeartbeatMgr();

   bool isNodeNew;

   NodeType nodeType = getNodeType();
   std::string nodeID(getNodeID() );

   NicAddressList nicList;
   parseNicList(&nicList);

   BitStore nodeFeatureFlags;
   parseNodeFeatureFlags(&nodeFeatureFlags);


   // check for empty nodeID; (sanity check, should never fail)

   if(unlikely(nodeID.empty() ) )
   {
      log.log(Log_WARNING, "Rejecting heartbeat of node with empty long ID "
         "from: " + peer + "; "
         "type: " + Node::nodeTypeToStr(nodeType) );

      return false;
   }


   if(nodeType == NODETYPE_Client)
   { // this is a client heartbeat
      NodeStoreClients* clients = app->getClientNodes();

      // construct node

      Node* node = RegisterNodeMsgEx::constructNode(
         nodeID, getNodeNumID(), getPortUDP(), getPortTCP(), nicList);

      node->setNodeType(getNodeType() );
      node->setFhgfsVersion(getFhgfsVersion() );
      node->setFeatureFlags(&nodeFeatureFlags);

      // add node to store (or update it)

      isNodeNew = clients->addOrUpdateNode(&node);
   }
   else
   { // this is a server heartbeat

      /* only accept new servers if nodeNumID is set
         (otherwise RegisterNodeMsg would need to be called first) */

      if(!getNodeNumID() )
      { /* shouldn't happen: this server would need to register first to get a nodeNumID assigned */

         log.log(Log_WARNING,
            "Rejecting heartbeat of node without numeric ID: " + nodeID + "; "
            "type: " + Node::nodeTypeToStr(nodeType) );

         return false;
      }

      // get the corresponding node store for this node type

      NodeStoreServers* servers = app->getServerStoreFromType(nodeType);
      if(unlikely(!servers) )
      {
         log.logErr(std::string("Invalid node type: ") + StringTk::intToStr(nodeType) );

         return false;
      }

      // check if adding a new server is allowed (in case this is a server)

      if(!RegisterNodeMsgEx::checkNewServerAllowed(servers, getNodeNumID(), nodeType) )
      { // this is a new server and adding was disabled
         log.log(Log_WARNING, std::string("Registration of new servers disabled. Rejecting: ") +
            nodeID + " (Type: " + Node::nodeTypeToStr(nodeType) + ")");

         return true;
      }

      // construct node

      Node* node = RegisterNodeMsgEx::constructNode(
         nodeID, getNodeNumID(), getPortUDP(), getPortTCP(), nicList);

      node->setNodeType(nodeType);
      node->setFhgfsVersion(getFhgfsVersion() );
      node->setFeatureFlags(&nodeFeatureFlags);

      std::string typedNodeID = node->getTypedNodeID();

      // add node to store (or update it)

      uint16_t confirmationNodeNumID;

      isNodeNew = servers->addOrUpdateNodeEx(&node, &confirmationNodeNumID);

      if(confirmationNodeNumID != getNodeNumID() )
      { // unable to add node to store
         log.log(Log_WARNING, "Node rejected because of ID conflict. "
            "Given numeric ID: " + StringTk::uintToStr(getNodeNumID() ) + "; "
            "string ID: " + getNodeID() + "; "
            "type: " + Node::nodeTypeToStr(nodeType) );

         return true;
      }

      // add to capacity pools

      if(nodeType == NODETYPE_Meta)
      {
         app->getMetaStateStore()->addIfNotExists(getNodeNumID(), CombinedTargetState(
            TargetReachabilityState_POFFLINE, TargetConsistencyState_GOOD) );

         bool isNewMetaTarget = metaCapacityPools->addIfNotExists(
            confirmationNodeNumID, CapacityPool_LOW);

         if(isNewMetaTarget)
            heartbeatMgr->notifyAsyncAddedNode(nodeID, getNodeNumID(), nodeType);

         // (note: storage targets get published through MapTargetMsg)
      }

      // handle root node information (if any is given)

      RegisterNodeMsgEx::processIncomingRoot(getRootNumID(), nodeType);

   } // end of server heartbeat specific handling

   
   if(isNodeNew)
   { // this node is new
      RegisterNodeMsgEx::processNewNode(nodeID, getNodeNumID(), nodeType, getFhgfsVersion(),
         &nicList, peer);
   }

   // send response

   MsgHelperAck::respondToAckRequest(this, fromAddr, sock,
      respBuf, bufLen, app->getDatagramListener() );

   return true;
}