Exemplo n.º 1
0
 private function nodeAdd(Node $node, $sortNodes = true)
 {
     $nodeId = $node->getIdHexStr();
     $filePath = null;
     if ($this->getDatadirBasePath()) {
         #$filePath = $this->getDatadirBasePath().'/node_'.$node->getIdHexStr().'.yml';
         #$filePath = $this->getDatadirBasePath().'/node_'.$node->getIdHexStr().'_'.mt_rand(1000, 9999).'.yml';
         #$filePath = $this->getDatadirBasePath().'/node_'.substr($nodeId, -5).'_'.time().'.yml';
         #$filePath = $this->getDatadirBasePath().'/node_'.substr($nodeId, -5).'.yml';
         $filePath = $this->getDatadirBasePath() . '/node_' . $nodeId . '.yml';
     }
     if (!$node->getFilePath()) {
         $node->setFilePath($filePath);
     }
     $node->setDatadirBasePath($this->getDatadirBasePath());
     $node->setBucket($this);
     $node->setDataChanged(true);
     #$this->nodesId++;
     #$this->nodes[$this->nodesId] = $node;
     $this->nodes[$nodeId] = $node;
     $this->isFull();
     $this->setDataChanged(true);
     /*if($sortNodes){
     			$this->nodesSort();
     		}*/
 }
Exemplo n.º 2
0
 public function testSaveNode()
 {
     $runName = uniqid('', true);
     $fileName = 'testfile_node_tcp1_' . date('Ymd_H') . '.yml';
     $node = new Node('test_data/' . $fileName);
     $node->setDatadirBasePath('test_data');
     $node->setDataChanged(true);
     $node->setIdHexStr('cafed00d-2131-4159-8e11-0b4dbadb1738');
     $node->setUri('tcp://192.168.241.21:25001');
     $node->setSslKeyPub(static::SSL_KEY_PUB1);
     $this->assertFalse($node->setSslKeyPub(static::SSL_KEY_PUB1));
     $this->assertEquals('cafed00d-2131-4159-8e11-0b4dbadb1738', $node->getIdHexStr());
     #$this->assertEquals('FC_BtK4HvbdX9wNQ6hGopSrFxs71SuuwMZra', $node->getSslKeyPubFingerprint());
     // @codingStandardsIgnoreStart
     $this->assertEquals('FC_TVqkkaeVwy5HMADDy1ErtdSsBUQ8Ch5zVPNYegNnHBVgejj8Mu8UYW78v5TyUC7aCB2Wo11hrMsfrVk', $node->getSslKeyPubFingerprint());
     // @codingStandardsIgnoreEnd
     $this->assertTrue((bool) $node->save());
 }