PHP Conference Japan 2024

Zookeeper 類別

(PECL zookeeper >= 0.1.0)

簡介

表示 ZooKeeper 會話。

類別概要

class Zookeeper {
/* 方法 */
public __construct(string $host = '', callable $watcher_cb = null, int $recv_timeout = 10000)
public addAuth(string $scheme, string $cert, callable $completion_cb = null): bool
public close(): void
public connect(string $host, callable $watcher_cb = null, int $recv_timeout = 10000): void
public create(
    string $path,
    string $value,
    array $acls,
    int $flags = null
): string
public delete(string $path, int $version = -1): bool
public exists(string $path, callable $watcher_cb = null): array
public get(
    string $path,
    callable $watcher_cb = null,
    array &$stat = null,
    int $max_size = 0
): string
public getAcl(string $path): array
public getChildren(string $path, callable $watcher_cb = null): array
public getClientId(): int
public getState(): int
public set(
    string $path,
    string $value,
    int $version = -1,
    array &$stat = null
): bool
public setAcl(string $path, int $version, array $acl): bool
public static setDebugLevel(int $logLevel): bool
public static setDeterministicConnOrder(bool $yesOrNo): bool
public setLogStream(resource $stream): bool
public setWatcher(callable $watcher_cb): bool
/* 常數 */
const int PERM_READ = 1;
const int PERM_WRITE = 2;
const int PERM_CREATE = 4;
const int PERM_DELETE = 8;
const int PERM_ADMIN = 16;
const int PERM_ALL = 31;
const int EPHEMERAL = 1;
const int SEQUENCE = 2;
const int LOG_LEVEL_ERROR = 1;
const int LOG_LEVEL_WARN = 2;
const int LOG_LEVEL_INFO = 3;
const int LOG_LEVEL_DEBUG = 4;
const int AUTH_FAILED_STATE = -113;
const int CONNECTED_STATE = 3;
const int READONLY_STATE = 5;
const int NOTCONNECTED_STATE = 999;
const int CREATED_EVENT = 1;
const int DELETED_EVENT = 2;
const int CHANGED_EVENT = 3;
const int CHILD_EVENT = 4;
const int SESSION_EVENT = -1;
const int SYSTEMERROR = -1;
const int CONNECTIONLOSS = -4;
const int MARSHALLINGERROR = -5;
const int UNIMPLEMENTED = -6;
const int OPERATIONTIMEOUT = -7;
const int BADARGUMENTS = -8;
const int INVALIDSTATE = -9;
const int NEWCONFIGNOQUORUM = -13;
const int RECONFIGINPROGRESS = -14;
const int OK = 0;
const int APIERROR = -100;
const int NONODE = -101;
const int NOAUTH = -102;
const int BADVERSION = -103;
const int NODEEXISTS = -110;
const int NOTEMPTY = -111;
const int SESSIONEXPIRED = -112;
const int INVALIDCALLBACK = -113;
const int INVALIDACL = -114;
const int AUTHFAILED = -115;
const int CLOSING = -116;
const int NOTHING = -117;
const int SESSIONMOVED = -118;
const int NOTREADONLY = -119;
const int NOWATCHER = -121;
const int RECONFIGDISABLED = -122;
}

預定義常數

ZooKeeper 權限

Zookeeper::PERM_READ

可以讀取節點的值並列出其子節點

Zookeeper::PERM_WRITE

可以設定節點的值

Zookeeper::PERM_CREATE

可以建立子節點

Zookeeper::PERM_DELETE

可以刪除子節點

Zookeeper::PERM_ADMIN

可以執行 set_acl()

Zookeeper::PERM_ALL

以上所有旗標的 OR 運算結果

ZooKeeper 建立旗標

Zookeeper::EPHEMERAL

如果設定 Zookeeper::EPHEMERAL 旗標,當用戶端連線中斷時,節點將會自動移除。

Zookeeper::SEQUENCE

如果設定 Zookeeper::SEQUENCE 旗標,則會在路徑名稱後附加一個單調遞增的唯一序號。序號長度固定為 10 位數字,並以 0 填充。

ZooKeeper 記錄層級

Zookeeper::LOG_LEVEL_ERROR

僅輸出錯誤訊息

Zookeeper::LOG_LEVEL_WARN

輸出錯誤/警告

Zookeeper::LOG_LEVEL_INFO

除了錯誤/警告外,還輸出重要動作訊息

Zookeeper::LOG_LEVEL_DEBUG

輸出所有訊息

ZooKeeper 狀態

Zookeeper::EXPIRED_SESSION_STATE

已連線但工作階段已過期

Zookeeper::AUTH_FAILED_STATE

已連線但驗證失敗

Zookeeper::CONNECTING_STATE

連線中

Zookeeper::ASSOCIATING_STATE

關聯中

Zookeeper::CONNECTED_STATE

已連線

Zookeeper::READONLY_STATE

TODO: 協助我們改進此擴充功能。

Zookeeper::NOTCONNECTED_STATE

連線失敗

ZooKeeper 監看類型

Zookeeper::CREATED_EVENT

已建立節點

這僅由監看不存在的節點產生。這些監看是使用 Zookeeper::exists 設定的。

Zookeeper::DELETED_EVENT

已刪除節點

這僅由監看節點產生。這些監看是使用 Zookeeper::exists 和 Zookeeper::get 設定的。

Zookeeper::CHANGED_EVENT

節點已變更

這僅由監看節點產生。這些監看是使用 Zookeeper::exists 和 Zookeeper::get 設定的。

Zookeeper::CHILD_EVENT

子節點列表發生變更

這僅由監看節點子節點列表觸發。這些監看是使用 Zookeeper::getChildren 設定的。

Zookeeper::SESSION_EVENT

連線階段已遺失

當客戶端與伺服器失去連線或重新連線時會產生此事件。

Zookeeper::NOTWATCHING_EVENT

監看已移除

當伺服器因為某些原因(可能是資源限制)不再為客戶端監看節點時,會產生此事件。

ZooKeeper 系統和伺服器端錯誤

Zookeeper::SYSTEMERROR

伺服器永遠不會擲回此錯誤,它不應被用於指示範圍之外。具體而言,大於此值的錯誤代碼,但小於 Zookeeper::APIERROR 的代碼,都是系統錯誤。

Zookeeper::RUNTIMEINCONSISTENCY

發現執行階段不一致的情況。

Zookeeper::DATAINCONSISTENCY

發現資料不一致的情況。

Zookeeper::CONNECTIONLOSS

與伺服器的連線已遺失。

Zookeeper::MARSHALLINGERROR

封送或解封送資料時發生錯誤。

Zookeeper::UNIMPLEMENTED

操作尚未實作。

Zookeeper::OPERATIONTIMEOUT

操作逾時。

Zookeeper::BADARGUMENTS

無效的引數。

Zookeeper::INVALIDSTATE

無效的 zhandle 狀態。

Zookeeper::NEWCONFIGNOQUORUM

沒有新的配置仲裁與最後提交的配置的領導者連線並保持最新狀態 - 請在新伺服器連線並同步後再嘗試呼叫重新配置。

自 ZooKeeper 3.5.0 起可用

Zookeeper::RECONFIGINPROGRESS

在另一個重新配置正在進行時,請求重新配置。目前不支援此操作。請重試。

自 ZooKeeper 3.5.0 起可用

ZooKeeper API 錯誤

Zookeeper::OK

一切正常。

Zookeeper::APIERROR

伺服器永遠不會擲回此錯誤,它不應被用於指示範圍之外。具體而言,大於此值的錯誤代碼是 API 錯誤(而小於此值表示 Zookeeper::SYSTEMERROR)。

Zookeeper::NONODE

節點不存在。

Zookeeper::NOAUTH

未經身份驗證。

Zookeeper::BADVERSION

版本衝突。

Zookeeper::NOCHILDRENFOREPHEMERALS

臨時節點不能有子節點。

Zookeeper::NODEEXISTS

節點已存在。

Zookeeper::NOTEMPTY

節點有子節點。

Zookeeper::SESSIONEXPIRED

連線階段已由伺服器過期。

Zookeeper::INVALIDCALLBACK

指定了無效的回呼。

Zookeeper::INVALIDACL

指定了無效的 ACL。

Zookeeper::AUTHFAILED

客戶端身份驗證失敗。

Zookeeper::CLOSING

ZooKeeper 正在關閉。

Zookeeper::NOTHING

(非錯誤)沒有伺服器響應要處理。

Zookeeper::SESSIONMOVED

連線階段已移至另一個伺服器,因此操作被忽略。

Zookeeper::NOTREADONLY

變更狀態的請求已傳遞到唯讀伺服器。

Zookeeper::EPHEMERALONLOCALSESSION

嘗試在本地連線階段建立臨時節點。

Zookeeper::NOWATCHER

找不到監看程式。

Zookeeper::RECONFIGDISABLED

當重新配置功能停用時,嘗試執行重新配置操作。

目錄

新增筆記

使用者貢獻的筆記

此頁面沒有使用者貢獻的筆記。
To Top