private function setChildBucketLower($distance) { if (!$this->childBucketLower) { list($newMaskByte, $newMaskBit, $newMaskBitValue) = $this->maskDecr(); if ($newMaskByte < Node::ID_LEN_BYTE && $newMaskBitValue > 0) { $filePath = null; if ($this->getDatadirBasePath()) { $filePath = $this->getDatadirBasePath() . '/bucket'; $filePath .= '_m' . sprintf('%02d', $newMaskByte) . '.' . $newMaskBit; $filePath .= '_d' . sprintf('%03d', $distance); $filePath .= '_l'; $filePath .= '.yml'; if (file_exists($filePath)) { // This should never happen. throw new RuntimeException('path for bucket alread exists: ' . $filePath); } } $bucket = new Bucket($filePath); $bucket->setDistance($distance); $bucket->setMaskByte($newMaskByte); $bucket->setMaskBit($newMaskBit); $bucket->setIsLower(true); $bucket->setDatadirBasePath($this->getDatadirBasePath()); $bucket->setLocalNode($this->getLocalNode()); $bucket->setDataChanged(true); $this->childBucketLower = $bucket; $this->setDataChanged(true); } /*else{ $msgOut = 'mask is at the end: /'.$maskByte.'/ /'.intToBin($maskBitValue).'/ ('.$maskBitValue.')'; throw new RuntimeException('setChildBucketLower: '.$msgOut'); # NOT_IMPLEMENTED }*/ } /*else{ #$msgOut = intToBin($this->childBucketLower->getMaskBit()).' ('.$this->childBucketLower->getMaskBit().')'; #fwrite(STDOUT, 'upper is set: '.$msgOut."\n"); }*/ }