Kafka\Protocol\Decoder::getError PHP 메소드

getError() 공개 정적인 메소드

get error
public static getError ( integer $errCode ) : string
$errCode integer
리턴 string
    public static function getError($errCode)
    {
        switch ($errCode) {
            case 0:
                $error = 'No error--it worked!';
                break;
            case -1:
                $error = 'An unexpected server error';
                break;
            case 1:
                $error = 'The requested offset is outside the range of offsets maintained by the server for the given topic/partition.';
                break;
            case 2:
                $error = 'This indicates that a message contents does not match its CRC';
                break;
            case 3:
                $error = 'This request is for a topic or partition that does not exist on this broker.';
                break;
            case 4:
                $error = 'The message has a negative size';
                break;
            case 5:
                $error = 'This error is thrown if we are in the middle of a leadership election and there is currently no leader for this partition and hence it is unavailable for writes';
                break;
            case 6:
                $error = 'This error is thrown if the client attempts to send messages to a replica that is not the leader for some partition. It indicates that the clients metadata is out of date.';
                break;
            case 7:
                $error = 'This error is thrown if the request exceeds the user-specified time limit in the request.';
                break;
            case 8:
                $error = 'This is not a client facing error and is used only internally by intra-cluster broker communication.';
                break;
            case 9:
                $error = 'The replica is not available for the requested topic-partition';
                break;
            case 10:
                $error = 'The server has a configurable maximum message size to avoid unbounded memory allocation. This error is thrown if the client attempt to produce a message larger than this maximum.';
                break;
            case 11:
                $error = 'Internal error code for broker-to-broker communication.';
                break;
            case 12:
                $error = 'If you specify a string larger than configured maximum for offset metadata';
                break;
            case 13:
                $error = 'The server disconnected before a response was received.';
                break;
            case 14:
                $error = 'The broker returns this error code for an offset fetch request if it is still loading offsets (after a leader change for that offsets topic partition).';
                break;
            case 15:
                $error = 'The broker returns this error code for consumer metadata requests or offset commit requests if the offsets topic has not yet been created.';
                break;
            case 16:
                $error = 'The broker returns this error code if it receives an offset fetch or commit request for a consumer group that it is not a coordinator for.';
                break;
            case 17:
                $error = 'The request attempted to perform an operation on an invalid topic.';
                break;
            case 18:
                $error = 'The request included message batch larger than the configured segment size on the server.';
                break;
            case 19:
                $error = 'Messages are rejected since there are fewer in-sync replicas than required.';
                break;
            case 20:
                $error = 'Messages are written to the log, but to fewer in-sync replicas than required.';
                break;
            case 21:
                $error = 'Produce request specified an invalid value for required acks.';
                break;
            case 22:
                $error = 'Specified group generation id is not valid.';
                break;
            case 23:
                $error = 'The group member\'s supported protocols are incompatible with those of existing members.';
                break;
            case 24:
                $error = 'The configured groupId is invalid';
                break;
            case 25:
                $error = 'The coordinator is not aware of this member.';
                break;
            case 26:
                $error = 'The session timeout is not within the range allowed by the broker (as configured by group.min.session.timeout.ms and group.max.session.timeout.ms).';
                break;
            case 27:
                $error = 'The group is rebalancing, so a rejoin is needed.';
                break;
            case 28:
                $error = 'The committing offset data size is not valid';
                break;
            case 29:
                $error = 'Topic authorization failed.';
                break;
            case 30:
                $error = 'Group authorization failed.';
                break;
            case 31:
                $error = 'Cluster authorization failed.';
                break;
            case 32:
                $error = 'The timestamp of the message is out of acceptable range.';
                break;
            case 33:
                $error = 'The broker does not support the requested SASL mechanism.';
                break;
            case 34:
                $error = 'Request is not valid given the current SASL state.';
                break;
            case 35:
                $error = 'The version of API is not supported.';
                break;
            default:
                $error = 'Unknown error';
        }
        return $error;
    }

Usage Example

예제 #1
0
 /**
  * get produce server offset
  *
  * @param string $topicName
  * @param integer $partitionId
  * @access public
  * @return int
  */
 public function getProduceOffset($timeLine = self::LAST_OFFSET)
 {
     $topicName = $this->topicName;
     $partitionId = $this->partitionId;
     $requestData = array('data' => array(array('topic_name' => $this->topicName, 'partitions' => array(array('partition_id' => $this->partitionId, 'time' => $timeLine, 'max_offset' => 1)))));
     $this->encoder->offsetRequest($requestData);
     $result = $this->decoder->offsetResponse();
     $this->client->freeStream($this->streamKey);
     if (!isset($result[$topicName][$partitionId]['offset'])) {
         if (isset($result[$topicName][$partitionId]['errCode'])) {
             throw new \Kafka\Exception(\Kafka\Protocol\Decoder::getError($result[$topicName][$partitionId]['errCode']));
         } else {
             throw new \Kafka\Exception('get offset failed. topic name:' . $this->topicName . ' partitionId: ' . $this->partitionId);
         }
     }
     return array_shift($result[$topicName][$partitionId]['offset']);
 }
All Usage Examples Of Kafka\Protocol\Decoder::getError