ZooDefs.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.apache.zookeeper;
  19. import java.util.ArrayList;
  20. import java.util.Collections;
  21. import org.apache.zookeeper.data.ACL;
  22. import org.apache.zookeeper.data.Id;
  23. public class ZooDefs {
  24. public interface OpCode {
  25. public final int notification = 0;
  26. public final int create = 1;
  27. public final int delete = 2;
  28. public final int exists = 3;
  29. public final int getData = 4;
  30. public final int setData = 5;
  31. public final int getACL = 6;
  32. public final int setACL = 7;
  33. public final int getChildren = 8;
  34. public final int sync = 9;
  35. public final int ping = 11;
  36. public final int auth = 100;
  37. public final int createSession = -10;
  38. public final int closeSession = -11;
  39. public final int error = -1;
  40. }
  41. public interface CreateFlags {
  42. int EPHEMERAL = 1 << 0;
  43. int SEQUENCE = 1 << 1;
  44. }
  45. public interface Perms {
  46. int READ = 1 << 0;
  47. int WRITE = 1 << 1;
  48. int CREATE = 1 << 2;
  49. int DELETE = 1 << 3;
  50. int ADMIN = 1 << 4;
  51. int ALL = READ | WRITE | CREATE | DELETE;
  52. }
  53. public interface Ids {
  54. /**
  55. * This Id represents anyone.
  56. */
  57. public final Id ANYONE_ID_UNSAFE = new Id("world", "anyone");
  58. /**
  59. * This Id is only usable to set ACLs. It will get substituted with the
  60. * Id's the client authenticated with.
  61. */
  62. public final Id AUTH_IDS = new Id("auth", "");
  63. /**
  64. * This is a completely open ACL with the exception of ADMIN permission.
  65. */
  66. public final ArrayList<ACL> OPEN_ACL_UNSAFE = new ArrayList<ACL>(
  67. Collections.singletonList(new ACL(Perms.ALL, ANYONE_ID_UNSAFE)));
  68. /**
  69. * This ACL gives the creators authentication id's all permissions.
  70. */
  71. public final ArrayList<ACL> CREATOR_ALL_ACL = new ArrayList<ACL>(
  72. Collections.singletonList(new ACL(Perms.ALL | Perms.ADMIN,
  73. AUTH_IDS)));
  74. /**
  75. * This ACL gives the world the ability to read.
  76. */
  77. public final ArrayList<ACL> READ_ACL_UNSAFE = new ArrayList<ACL>(
  78. Collections
  79. .singletonList(new ACL(Perms.READ, ANYONE_ID_UNSAFE)));
  80. }
  81. final public static String[] opNames = { "notification", "create",
  82. "delete", "exists", "getData", "setData", "getACL", "setACL",
  83. "getChildren", "getMaxChildren", "setMaxChildren", "ping" };
  84. }