2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.datastore.persisted;
10 import com.google.common.io.ByteArrayDataOutput;
11 import com.google.common.io.ByteStreams;
12 import java.io.IOException;
13 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Payload persisted when a local history is completely purged, i.e. the frontend has removed it from its tracking.
19 * It contains a {@link LocalHistoryIdentifier}.
21 * @author Robert Varga
23 public final class PurgeLocalHistoryPayload extends AbstractIdentifiablePayload<LocalHistoryIdentifier> {
24 private static final Logger LOG = LoggerFactory.getLogger(PurgeLocalHistoryPayload.class);
26 private static final long serialVersionUID = 1L;
27 private static final int PROXY_SIZE = externalizableProxySize(PH::new);
29 PurgeLocalHistoryPayload(final LocalHistoryIdentifier historyId, final byte[] serialized) {
30 super(historyId, serialized);
33 public static PurgeLocalHistoryPayload create(final LocalHistoryIdentifier historyId,
34 final int initialSerializedBufferCapacity) {
35 final ByteArrayDataOutput out = ByteStreams.newDataOutput(initialSerializedBufferCapacity);
37 historyId.writeTo(out);
38 } catch (IOException e) {
39 // This should never happen
40 LOG.error("Failed to serialize {}", historyId, e);
41 throw new IllegalStateException("Failed to serialize " + historyId, e);
43 return new PurgeLocalHistoryPayload(historyId, out.toByteArray());
47 protected PH externalizableProxy(final byte[] serialized) {
48 return new PH(serialized);
52 protected int externalizableProxySize() {