Skip to content

Commit

Permalink
[FLINK-26231][state/changelog] Fix ChangelogStateBackendHandle constr…
Browse files Browse the repository at this point in the history
…uctor
  • Loading branch information
rkhachatryan committed Feb 18, 2022
1 parent ac3ad13 commit 8d4d109
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public ChangelogStateBackendHandleImpl(
materialized,
nonMaterialized,
keyGroupRange,
persistedSizeOfThisCheckpoint,
materializationID,
persistedSizeOfThisCheckpoint,
StateHandleID.randomStateHandleId());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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:https://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 org.apache.flink.runtime.state.changelog;

import org.apache.flink.runtime.state.KeyGroupRange;
import org.apache.flink.runtime.state.changelog.ChangelogStateBackendHandle.ChangelogStateBackendHandleImpl;

import org.junit.Test;

import static java.util.Collections.emptyList;
import static org.apache.flink.runtime.state.StateHandleID.randomStateHandleId;
import static org.junit.Assert.assertEquals;

public class ChangelogStateBackendHandleTest {

@Test
public void testPublicConstructor() {
long materializationID = 1L;
long size = 2L;
validateHandle(
materializationID,
size,
new ChangelogStateBackendHandleImpl(
emptyList(), emptyList(), KeyGroupRange.of(1, 2), materializationID, size));
}

@Test
public void testRestore() {
long materializationID = 1L;
long size = 2L;
validateHandle(
materializationID,
size,
ChangelogStateBackendHandleImpl.restore(
emptyList(),
emptyList(),
KeyGroupRange.of(1, 2),
materializationID,
size,
randomStateHandleId()));
}

private void validateHandle(
long materializationID, long size, ChangelogStateBackendHandleImpl handle) {
assertEquals(materializationID, handle.getMaterializationID());
assertEquals(size, handle.getCheckpointedSize());
}
}

0 comments on commit 8d4d109

Please sign in to comment.