All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.debezium.connector.db2.Db2Partition Maven / Gradle / Ivy

There is a newer version: 3.0.0.CR1
Show newest version
/*
 * Copyright Debezium Authors.
 *
 * Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
 */
package io.debezium.connector.db2;

import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import io.debezium.pipeline.spi.Partition;
import io.debezium.util.Collect;

public class Db2Partition implements Partition {
    private static final String SERVER_PARTITION_KEY = "server";

    private final String serverName;

    public Db2Partition(String serverName) {
        this.serverName = serverName;
    }

    @Override
    public Map getSourcePartition() {
        return Collect.hashMapOf(SERVER_PARTITION_KEY, serverName);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        final Db2Partition other = (Db2Partition) obj;
        return Objects.equals(serverName, other.serverName);
    }

    @Override
    public int hashCode() {
        return serverName.hashCode();
    }

    @Override
    public String toString() {
        return "Db2Partition [sourcePartition=" + getSourcePartition() + "]";
    }

    static class Provider implements Partition.Provider {
        private final Db2ConnectorConfig connectorConfig;

        Provider(Db2ConnectorConfig connectorConfig) {
            this.connectorConfig = connectorConfig;
        }

        @Override
        public Set getPartitions() {
            return Collections.singleton(new Db2Partition(connectorConfig.getLogicalName()));
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy