Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.store.primitives.resources.impl; |
| 17 | |
| 18 | import io.atomix.catalyst.buffer.BufferInput; |
| 19 | import io.atomix.catalyst.buffer.BufferOutput; |
| 20 | import io.atomix.catalyst.serializer.CatalystSerializable; |
Madan Jampani | fc98177 | 2016-02-16 09:46:42 -0800 | [diff] [blame] | 21 | import io.atomix.catalyst.serializer.SerializableTypeResolver; |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 22 | import io.atomix.catalyst.serializer.Serializer; |
Madan Jampani | fc98177 | 2016-02-16 09:46:42 -0800 | [diff] [blame] | 23 | import io.atomix.catalyst.serializer.SerializerRegistry; |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 24 | import io.atomix.catalyst.util.Assert; |
Madan Jampani | 3a9911c | 2016-02-21 11:25:45 -0800 | [diff] [blame] | 25 | import io.atomix.copycat.Command; |
| 26 | import io.atomix.copycat.Query; |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 27 | |
| 28 | import java.util.Collection; |
| 29 | import java.util.Map; |
| 30 | import java.util.Set; |
| 31 | |
| 32 | import org.onlab.util.Match; |
Jordan Halterman | 948d659 | 2017-04-20 17:18:24 -0700 | [diff] [blame^] | 33 | import org.onosproject.store.primitives.MapUpdate; |
Madan Jampani | cadd70b | 2016-02-08 13:45:43 -0800 | [diff] [blame] | 34 | import org.onosproject.store.primitives.TransactionId; |
Jordan Halterman | 948d659 | 2017-04-20 17:18:24 -0700 | [diff] [blame^] | 35 | import org.onosproject.store.service.TransactionLog; |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 36 | import org.onosproject.store.service.Versioned; |
| 37 | |
| 38 | import com.google.common.base.MoreObjects; |
| 39 | |
| 40 | /** |
| 41 | * {@link AtomixConsistentMap} resource state machine operations. |
| 42 | */ |
| 43 | public final class AtomixConsistentMapCommands { |
| 44 | |
| 45 | private AtomixConsistentMapCommands() { |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Abstract map command. |
| 50 | */ |
| 51 | @SuppressWarnings("serial") |
| 52 | public abstract static class MapCommand<V> implements Command<V>, CatalystSerializable { |
| 53 | |
| 54 | @Override |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 55 | public String toString() { |
| 56 | return MoreObjects.toStringHelper(getClass()) |
| 57 | .toString(); |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Abstract map query. |
| 71 | */ |
| 72 | @SuppressWarnings("serial") |
| 73 | public abstract static class MapQuery<V> implements Query<V>, CatalystSerializable { |
| 74 | |
| 75 | @Override |
| 76 | public ConsistencyLevel consistency() { |
Madan Jampani | 5ddaf19 | 2016-04-04 07:39:31 -0700 | [diff] [blame] | 77 | return ConsistencyLevel.SEQUENTIAL; |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public String toString() { |
| 82 | return MoreObjects.toStringHelper(getClass()) |
| 83 | .toString(); |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Abstract key-based query. |
| 97 | */ |
| 98 | @SuppressWarnings("serial") |
| 99 | public abstract static class KeyQuery<V> extends MapQuery<V> { |
| 100 | protected String key; |
| 101 | |
| 102 | public KeyQuery() { |
| 103 | } |
| 104 | |
| 105 | public KeyQuery(String key) { |
| 106 | this.key = Assert.notNull(key, "key"); |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Returns the key. |
| 111 | * @return key |
| 112 | */ |
| 113 | public String key() { |
| 114 | return key; |
| 115 | } |
| 116 | |
| 117 | @Override |
| 118 | public String toString() { |
| 119 | return MoreObjects.toStringHelper(getClass()) |
| 120 | .add("key", key) |
| 121 | .toString(); |
| 122 | } |
| 123 | |
| 124 | @Override |
| 125 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
| 126 | super.writeObject(buffer, serializer); |
| 127 | serializer.writeObject(key, buffer); |
| 128 | } |
| 129 | |
| 130 | @Override |
| 131 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
| 132 | super.readObject(buffer, serializer); |
| 133 | key = serializer.readObject(buffer); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | /** |
Aaron Kruglikov | 56423ba | 2016-04-19 13:39:16 -0700 | [diff] [blame] | 138 | * Abstract value-based query. |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 139 | */ |
| 140 | @SuppressWarnings("serial") |
| 141 | public abstract static class ValueQuery<V> extends MapQuery<V> { |
| 142 | protected byte[] value; |
| 143 | |
| 144 | public ValueQuery() { |
| 145 | } |
| 146 | |
| 147 | public ValueQuery(byte[] value) { |
| 148 | this.value = Assert.notNull(value, "value"); |
| 149 | } |
| 150 | |
| 151 | /** |
Aaron Kruglikov | 56423ba | 2016-04-19 13:39:16 -0700 | [diff] [blame] | 152 | * Returns the value. |
| 153 | * @return value |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 154 | */ |
| 155 | public byte[] value() { |
| 156 | return value; |
| 157 | } |
| 158 | |
| 159 | @Override |
Aaron Kruglikov | b56c296 | 2016-04-04 17:03:24 -0700 | [diff] [blame] | 160 | public String toString() { |
| 161 | return MoreObjects.toStringHelper(getClass()) |
| 162 | .add("value", value) |
| 163 | .toString(); |
| 164 | } |
| 165 | |
| 166 | @Override |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 167 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
| 168 | super.writeObject(buffer, serializer); |
| 169 | serializer.writeObject(value, buffer); |
| 170 | } |
| 171 | |
| 172 | @Override |
| 173 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
| 174 | super.readObject(buffer, serializer); |
| 175 | value = serializer.readObject(buffer); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Contains key command. |
| 181 | */ |
| 182 | @SuppressWarnings("serial") |
| 183 | public static class ContainsKey extends KeyQuery<Boolean> { |
| 184 | public ContainsKey() { |
| 185 | } |
| 186 | |
| 187 | public ContainsKey(String key) { |
| 188 | super(key); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | /** |
Aaron Kruglikov | 56423ba | 2016-04-19 13:39:16 -0700 | [diff] [blame] | 193 | * Contains value command. |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 194 | */ |
| 195 | @SuppressWarnings("serial") |
| 196 | public static class ContainsValue extends ValueQuery<Boolean> { |
| 197 | public ContainsValue() { |
| 198 | } |
| 199 | |
| 200 | public ContainsValue(byte[] value) { |
| 201 | super(value); |
| 202 | } |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | /** |
Jordan Halterman | 948d659 | 2017-04-20 17:18:24 -0700 | [diff] [blame^] | 206 | * Transaction begin query. |
| 207 | */ |
| 208 | public static class TransactionBegin extends MapQuery<Long> { |
| 209 | @Override |
| 210 | public ConsistencyLevel consistency() { |
| 211 | return ConsistencyLevel.LINEARIZABLE; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | /** |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 216 | * Map prepare command. |
| 217 | */ |
| 218 | @SuppressWarnings("serial") |
| 219 | public static class TransactionPrepare extends MapCommand<PrepareResult> { |
Jordan Halterman | 948d659 | 2017-04-20 17:18:24 -0700 | [diff] [blame^] | 220 | private TransactionLog<MapUpdate<String, byte[]>> transactionLog; |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 221 | |
| 222 | public TransactionPrepare() { |
| 223 | } |
| 224 | |
Jordan Halterman | 948d659 | 2017-04-20 17:18:24 -0700 | [diff] [blame^] | 225 | public TransactionPrepare(TransactionLog<MapUpdate<String, byte[]>> transactionLog) { |
| 226 | this.transactionLog = transactionLog; |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 227 | } |
| 228 | |
Jordan Halterman | 948d659 | 2017-04-20 17:18:24 -0700 | [diff] [blame^] | 229 | public TransactionLog<MapUpdate<String, byte[]>> transactionLog() { |
| 230 | return transactionLog; |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | @Override |
| 234 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
| 235 | super.writeObject(buffer, serializer); |
Jordan Halterman | 948d659 | 2017-04-20 17:18:24 -0700 | [diff] [blame^] | 236 | serializer.writeObject(transactionLog, buffer); |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | @Override |
| 240 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
| 241 | super.readObject(buffer, serializer); |
Jordan Halterman | 948d659 | 2017-04-20 17:18:24 -0700 | [diff] [blame^] | 242 | transactionLog = serializer.readObject(buffer); |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | @Override |
| 246 | public String toString() { |
| 247 | return MoreObjects.toStringHelper(getClass()) |
Jordan Halterman | 948d659 | 2017-04-20 17:18:24 -0700 | [diff] [blame^] | 248 | .add("transactionLog", transactionLog) |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 249 | .toString(); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | /** |
Madan Jampani | 542d9e2 | 2016-04-05 15:39:55 -0700 | [diff] [blame] | 254 | * Map prepareAndCommit command. |
| 255 | */ |
| 256 | @SuppressWarnings("serial") |
| 257 | public static class TransactionPrepareAndCommit extends TransactionPrepare { |
| 258 | public TransactionPrepareAndCommit() { |
| 259 | } |
| 260 | |
Jordan Halterman | 948d659 | 2017-04-20 17:18:24 -0700 | [diff] [blame^] | 261 | public TransactionPrepareAndCommit(TransactionLog<MapUpdate<String, byte[]>> transactionLog) { |
| 262 | super(transactionLog); |
Madan Jampani | 542d9e2 | 2016-04-05 15:39:55 -0700 | [diff] [blame] | 263 | } |
Jordan Halterman | 820e39f | 2017-02-05 22:15:36 -0800 | [diff] [blame] | 264 | |
| 265 | @Override |
| 266 | public CompactionMode compaction() { |
| 267 | return CompactionMode.QUORUM; |
| 268 | } |
Madan Jampani | 542d9e2 | 2016-04-05 15:39:55 -0700 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | /** |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 272 | * Map transaction commit command. |
| 273 | */ |
| 274 | @SuppressWarnings("serial") |
| 275 | public static class TransactionCommit extends MapCommand<CommitResult> { |
| 276 | private TransactionId transactionId; |
| 277 | |
| 278 | public TransactionCommit() { |
| 279 | } |
| 280 | |
| 281 | public TransactionCommit(TransactionId transactionId) { |
| 282 | this.transactionId = transactionId; |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * Returns the transaction identifier. |
| 287 | * @return transaction id |
| 288 | */ |
| 289 | public TransactionId transactionId() { |
| 290 | return transactionId; |
| 291 | } |
| 292 | |
| 293 | @Override |
| 294 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
| 295 | super.writeObject(buffer, serializer); |
| 296 | serializer.writeObject(transactionId, buffer); |
| 297 | } |
| 298 | |
| 299 | @Override |
| 300 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
| 301 | super.readObject(buffer, serializer); |
| 302 | transactionId = serializer.readObject(buffer); |
| 303 | } |
| 304 | |
| 305 | @Override |
Jordan Halterman | 820e39f | 2017-02-05 22:15:36 -0800 | [diff] [blame] | 306 | public CompactionMode compaction() { |
| 307 | return CompactionMode.TOMBSTONE; |
| 308 | } |
| 309 | |
| 310 | @Override |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 311 | public String toString() { |
| 312 | return MoreObjects.toStringHelper(getClass()) |
| 313 | .add("transactionId", transactionId) |
| 314 | .toString(); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | /** |
| 319 | * Map transaction rollback command. |
| 320 | */ |
| 321 | @SuppressWarnings("serial") |
| 322 | public static class TransactionRollback extends MapCommand<RollbackResult> { |
| 323 | private TransactionId transactionId; |
| 324 | |
| 325 | public TransactionRollback() { |
| 326 | } |
| 327 | |
| 328 | public TransactionRollback(TransactionId transactionId) { |
| 329 | this.transactionId = transactionId; |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Returns the transaction identifier. |
| 334 | * @return transaction id |
| 335 | */ |
| 336 | public TransactionId transactionId() { |
| 337 | return transactionId; |
| 338 | } |
| 339 | |
| 340 | @Override |
| 341 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
| 342 | super.writeObject(buffer, serializer); |
| 343 | serializer.writeObject(transactionId, buffer); |
| 344 | } |
| 345 | |
| 346 | @Override |
| 347 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
| 348 | super.readObject(buffer, serializer); |
| 349 | transactionId = serializer.readObject(buffer); |
| 350 | } |
| 351 | |
| 352 | @Override |
Jordan Halterman | 820e39f | 2017-02-05 22:15:36 -0800 | [diff] [blame] | 353 | public CompactionMode compaction() { |
| 354 | return CompactionMode.TOMBSTONE; |
| 355 | } |
| 356 | |
| 357 | @Override |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 358 | public String toString() { |
| 359 | return MoreObjects.toStringHelper(getClass()) |
| 360 | .add("transactionId", transactionId) |
| 361 | .toString(); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | /** |
| 366 | * Map update command. |
| 367 | */ |
| 368 | @SuppressWarnings("serial") |
| 369 | public static class UpdateAndGet extends MapCommand<MapEntryUpdateResult<String, byte[]>> { |
| 370 | private String key; |
| 371 | private byte[] value; |
| 372 | private Match<byte[]> valueMatch; |
| 373 | private Match<Long> versionMatch; |
| 374 | |
| 375 | public UpdateAndGet() { |
| 376 | } |
| 377 | |
| 378 | public UpdateAndGet(String key, |
| 379 | byte[] value, |
| 380 | Match<byte[]> valueMatch, |
| 381 | Match<Long> versionMatch) { |
| 382 | this.key = key; |
| 383 | this.value = value; |
| 384 | this.valueMatch = valueMatch; |
| 385 | this.versionMatch = versionMatch; |
| 386 | } |
| 387 | |
| 388 | /** |
| 389 | * Returns the key. |
| 390 | * @return key |
| 391 | */ |
| 392 | public String key() { |
| 393 | return this.key; |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Returns the value. |
| 398 | * @return value |
| 399 | */ |
| 400 | public byte[] value() { |
| 401 | return this.value; |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Returns the value match. |
| 406 | * @return value match |
| 407 | */ |
| 408 | public Match<byte[]> valueMatch() { |
| 409 | return this.valueMatch; |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * Returns the version match. |
| 414 | * @return version match |
| 415 | */ |
| 416 | public Match<Long> versionMatch() { |
| 417 | return this.versionMatch; |
| 418 | } |
| 419 | |
| 420 | @Override |
| 421 | public CompactionMode compaction() { |
Jordan Halterman | 73e5cce | 2017-03-02 17:35:57 -0800 | [diff] [blame] | 422 | return value == null ? CompactionMode.TOMBSTONE : CompactionMode.FULL; |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | @Override |
| 426 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
| 427 | super.writeObject(buffer, serializer); |
| 428 | serializer.writeObject(key, buffer); |
| 429 | serializer.writeObject(value, buffer); |
| 430 | serializer.writeObject(valueMatch, buffer); |
| 431 | serializer.writeObject(versionMatch, buffer); |
| 432 | } |
| 433 | |
| 434 | @Override |
| 435 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
| 436 | super.readObject(buffer, serializer); |
| 437 | key = serializer.readObject(buffer); |
| 438 | value = serializer.readObject(buffer); |
| 439 | valueMatch = serializer.readObject(buffer); |
| 440 | versionMatch = serializer.readObject(buffer); |
| 441 | } |
| 442 | |
| 443 | @Override |
| 444 | public String toString() { |
| 445 | return MoreObjects.toStringHelper(getClass()) |
| 446 | .add("key", key) |
| 447 | .add("value", value) |
| 448 | .add("valueMatch", valueMatch) |
| 449 | .add("versionMatch", versionMatch) |
| 450 | .toString(); |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Get query. |
| 456 | */ |
| 457 | @SuppressWarnings("serial") |
| 458 | public static class Get extends KeyQuery<Versioned<byte[]>> { |
| 459 | public Get() { |
| 460 | } |
| 461 | |
| 462 | public Get(String key) { |
| 463 | super(key); |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | /** |
Jordan Halterman | f627244 | 2017-04-20 02:18:08 -0700 | [diff] [blame] | 468 | * Get or default query. |
| 469 | */ |
| 470 | @SuppressWarnings("serial") |
| 471 | public static class GetOrDefault extends KeyQuery<Versioned<byte[]>> { |
| 472 | private byte[] defaultValue; |
| 473 | |
| 474 | public GetOrDefault() { |
| 475 | } |
| 476 | |
| 477 | public GetOrDefault(String key, byte[] defaultValue) { |
| 478 | super(key); |
| 479 | this.defaultValue = defaultValue; |
| 480 | } |
| 481 | |
| 482 | /** |
| 483 | * Returns the default value. |
| 484 | * |
| 485 | * @return the default value |
| 486 | */ |
| 487 | public byte[] defaultValue() { |
| 488 | return defaultValue; |
| 489 | } |
| 490 | |
| 491 | @Override |
| 492 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
| 493 | super.writeObject(buffer, serializer); |
| 494 | serializer.writeObject(defaultValue, buffer); |
| 495 | } |
| 496 | |
| 497 | @Override |
| 498 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
| 499 | super.readObject(buffer, serializer); |
| 500 | defaultValue = serializer.readObject(buffer); |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | /** |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 505 | * Is empty query. |
| 506 | */ |
| 507 | @SuppressWarnings("serial") |
| 508 | public static class IsEmpty extends MapQuery<Boolean> { |
| 509 | } |
| 510 | |
| 511 | /** |
| 512 | * KeySet query. |
| 513 | */ |
| 514 | @SuppressWarnings("serial") |
| 515 | public static class KeySet extends MapQuery<Set<String>> { |
| 516 | } |
| 517 | |
| 518 | /** |
Aaron Kruglikov | b56c296 | 2016-04-04 17:03:24 -0700 | [diff] [blame] | 519 | * ValueSet query. |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 520 | */ |
| 521 | @SuppressWarnings("serial") |
| 522 | public static class Values extends MapQuery<Collection<Versioned<byte[]>>> { |
| 523 | } |
| 524 | |
| 525 | /** |
Aaron Kruglikov | b56c296 | 2016-04-04 17:03:24 -0700 | [diff] [blame] | 526 | * EntrySet query. |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 527 | */ |
| 528 | @SuppressWarnings("serial") |
| 529 | public static class EntrySet extends MapQuery<Set<Map.Entry<String, Versioned<byte[]>>>> { |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * Size query. |
| 534 | */ |
| 535 | @SuppressWarnings("serial") |
| 536 | public static class Size extends MapQuery<Integer> { |
| 537 | } |
| 538 | |
| 539 | /** |
| 540 | * Clear command. |
| 541 | */ |
| 542 | @SuppressWarnings("serial") |
| 543 | public static class Clear extends MapCommand<MapEntryUpdateResult.Status> { |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 544 | @Override |
| 545 | public CompactionMode compaction() { |
Jordan Halterman | 820e39f | 2017-02-05 22:15:36 -0800 | [diff] [blame] | 546 | return CompactionMode.TOMBSTONE; |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 547 | } |
| 548 | } |
| 549 | |
| 550 | /** |
| 551 | * Change listen. |
| 552 | */ |
| 553 | @SuppressWarnings("serial") |
| 554 | public static class Listen implements Command<Void>, CatalystSerializable { |
| 555 | @Override |
| 556 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
| 557 | } |
| 558 | |
| 559 | @Override |
| 560 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
| 561 | } |
Jordan Halterman | 820e39f | 2017-02-05 22:15:36 -0800 | [diff] [blame] | 562 | |
| 563 | @Override |
| 564 | public CompactionMode compaction() { |
| 565 | return CompactionMode.QUORUM; |
| 566 | } |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | /** |
| 570 | * Change unlisten. |
| 571 | */ |
| 572 | @SuppressWarnings("serial") |
| 573 | public static class Unlisten implements Command<Void>, CatalystSerializable { |
| 574 | @Override |
| 575 | public void writeObject(BufferOutput<?> buffer, Serializer serializer) { |
| 576 | } |
| 577 | |
| 578 | @Override |
| 579 | public void readObject(BufferInput<?> buffer, Serializer serializer) { |
| 580 | } |
Jordan Halterman | 820e39f | 2017-02-05 22:15:36 -0800 | [diff] [blame] | 581 | |
| 582 | @Override |
| 583 | public CompactionMode compaction() { |
| 584 | return CompactionMode.TOMBSTONE; |
| 585 | } |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 586 | } |
Madan Jampani | fc98177 | 2016-02-16 09:46:42 -0800 | [diff] [blame] | 587 | |
| 588 | /** |
| 589 | * Map command type resolver. |
| 590 | */ |
| 591 | public static class TypeResolver implements SerializableTypeResolver { |
| 592 | @Override |
| 593 | public void resolve(SerializerRegistry registry) { |
| 594 | registry.register(ContainsKey.class, -761); |
| 595 | registry.register(ContainsValue.class, -762); |
| 596 | registry.register(Get.class, -763); |
Jordan Halterman | f627244 | 2017-04-20 02:18:08 -0700 | [diff] [blame] | 597 | registry.register(GetOrDefault.class, -778); |
Madan Jampani | fc98177 | 2016-02-16 09:46:42 -0800 | [diff] [blame] | 598 | registry.register(EntrySet.class, -764); |
| 599 | registry.register(Values.class, -765); |
| 600 | registry.register(KeySet.class, -766); |
| 601 | registry.register(Clear.class, -767); |
| 602 | registry.register(IsEmpty.class, -768); |
| 603 | registry.register(Size.class, -769); |
| 604 | registry.register(Listen.class, -770); |
| 605 | registry.register(Unlisten.class, -771); |
Jordan Halterman | 948d659 | 2017-04-20 17:18:24 -0700 | [diff] [blame^] | 606 | registry.register(TransactionBegin.class, -777); |
Madan Jampani | fc98177 | 2016-02-16 09:46:42 -0800 | [diff] [blame] | 607 | registry.register(TransactionPrepare.class, -772); |
| 608 | registry.register(TransactionCommit.class, -773); |
| 609 | registry.register(TransactionRollback.class, -774); |
Madan Jampani | 542d9e2 | 2016-04-05 15:39:55 -0700 | [diff] [blame] | 610 | registry.register(TransactionPrepareAndCommit.class, -775); |
| 611 | registry.register(UpdateAndGet.class, -776); |
Madan Jampani | fc98177 | 2016-02-16 09:46:42 -0800 | [diff] [blame] | 612 | } |
| 613 | } |
Madan Jampani | 5e5b3d6 | 2016-02-01 16:03:33 -0800 | [diff] [blame] | 614 | } |