package org.apache.bookkeeper.proto; /* * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ /** * The packets of the Bookie protocol all have a 4-byte integer indicating the * type of request or response at the very beginning of the packet followed by a * payload. * */ public interface BookieProtocol { /** * The Add entry request payload will be a ledger entry exactly as it should * be logged. The response payload will be a 4-byte integer that has the * error code followed by the 8-byte ledger number and 8-byte entry number * of the entry written. */ public static final int ADDENTRY = 1; /** * The Read entry request payload will be the ledger number and entry number * to read. (The ledger number is an 8-byte integer and the entry number is * a 8-byte integer.) The response payload will be a 4-byte integer * representing an error code and a ledger entry if the error code is EOK, * otherwise it will be the 8-byte ledger number and the 4-byte entry number * requested. (Note that the first sixteen bytes of the entry happen to be * the ledger number and entry number as well.) */ public static final int READENTRY = 2; /** * The error code that indicates success */ public static final int EOK = 0; /** * The error code that indicates that the ledger does not exist */ public static final int ENOLEDGER = 1; /** * The error code that indicates that the requested entry does not exist */ public static final int ENOENTRY = 2; /** * The error code that indicates an invalid request type */ public static final int EBADREQ = 100; /** * General error occurred at the server */ public static final int EIO = 101; /** * Unauthorized access to ledger */ public static final int EUA = 102; }