import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
+import com.esotericsoftware.kryo.serializers.DefaultSerializers.LongSerializer;
import com.google.common.base.MoreObjects;
import com.google.common.base.Stopwatch;
import io.atomix.storage.journal.Indexed;
}
private static final Logger LOG = LoggerFactory.getLogger(SegmentedJournalActor.class);
- private static final Namespace DELETE_NAMESPACE = Namespace.builder().register(Long.class).build();
+ private static final Namespace DELETE_NAMESPACE = Namespace.builder()
+ .register(new LongSerializer(), Long.class)
+ .build();
private static final int DELETE_SEGMENT_SIZE = 64 * 1024;
private final String persistenceId;
return this;
}
- /**
- * Registers classes to be serialized using Kryo default serializer.
- *
- * @param expectedTypes list of classes
- * @return this
- */
- public Builder register(final Class<?>... expectedTypes) {
- for (Class<?> clazz : expectedTypes) {
- types.add(Pair.of(new Class<?>[]{clazz}, null));
- }
- return this;
- }
-
/**
* Registers serializer for the given set of classes.
* <p>
*/
package io.atomix.storage.journal;
+import com.esotericsoftware.kryo.serializers.DefaultArraySerializers.ByteArraySerializer;
import io.atomix.utils.serializer.Namespace;
import org.junit.After;
import org.junit.Before;
@RunWith(Parameterized.class)
public abstract class AbstractJournalTest {
private static final Namespace NAMESPACE = Namespace.builder()
- .register(TestEntry.class)
- .register(byte[].class)
+ .register(new TestEntrySerializer(), TestEntry.class)
+ .register(new ByteArraySerializer(), byte[].class)
.build();
protected static final TestEntry ENTRY = new TestEntry(32);
--- /dev/null
+/*
+ * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * Licensed 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.
+ */
+package io.atomix.storage.journal;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.Serializer;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+import com.esotericsoftware.kryo.serializers.DefaultArraySerializers.ByteArraySerializer;
+
+class TestEntrySerializer extends Serializer<TestEntry> {
+ private static final ByteArraySerializer BA_SERIALIZER = new ByteArraySerializer();
+
+ @Override
+ public void write(Kryo kryo, Output output, TestEntry object) {
+ kryo.writeObjectOrNull(output, object.bytes(), BA_SERIALIZER);
+ }
+
+ @Override
+ public TestEntry read(Kryo kryo, Input input, Class<TestEntry> type) {
+ return new TestEntry(kryo.readObjectOrNull(input, byte[].class, BA_SERIALIZER));
+ }
+}