Example #1
0
 public function load()
 {
     #print __CLASS__.'->'.__FUNCTION__.''."\n";
     if (parent::load()) {
         if ($this->data) {
             if (array_key_exists('nodes', $this->data) && $this->data['nodes']) {
                 foreach ($this->data['nodes'] as $nodeId => $nodeAr) {
                     if (file_exists($nodeAr['path'])) {
                         $node = new Node($nodeAr['path']);
                         $node->setDatadirBasePath($this->getDatadirBasePath());
                         if ($node->load()) {
                             $this->nodes[$nodeId] = $node;
                         }
                     }
                 }
             }
         }
         unset($this->data['nodes']);
         return true;
     }
     return false;
 }
Example #2
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();
     		}*/
 }
Example #3
0
 public function testLoadNode2()
 {
     $runName = uniqid('', true);
     $fileName = 'testfile_node_tcp2_' . date('Ymd_His') . '_' . $runName . '.yml';
     $node = new Node('test_data/' . $fileName);
     $node->setDatadirBasePath('test_data');
     $this->assertFalse($node->load());
 }