<commit_before>/*
 * Copyright (c) 2016 Intel Corporation.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.netvirt.neutronvpn;

import com.google.common.collect.Maps;
import java.util.Map;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.Hostconfigs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.Hostconfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.HostconfigBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIds;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class NeutronHostConfigChangeListener extends AsyncDataTreeChangeListenerBase<Node,
        NeutronHostConfigChangeListener> implements AutoCloseable {
    private static final Logger LOG = LoggerFactory.getLogger(NeutronHostConfigChangeListener.class);
    private final DataBroker dataBroker;
    private final SouthboundUtils southboundUtils;
    private final MdsalUtils mdsalUtils;
    private static final String OS_HOST_CONFIG_HOST_ID_KEY = "odl_os_hostconfig_hostid";
    private static final String OS_HOST_CONFIG_CONFIG_KEY_PREFIX = "odl_os_hostconfig_config_odl_";
    private static int HOST_TYPE_STR_LEN = 8;

    private enum Action {
        ADD,
        UPDATE,
        DELETE
    }

    public NeutronHostConfigChangeListener(final DataBroker dataBroker){
        super(Node.class,NeutronHostConfigChangeListener.class);
        this.dataBroker = dataBroker;
        this.mdsalUtils = new MdsalUtils(dataBroker);
        this.southboundUtils = new SouthboundUtils(mdsalUtils);
    }

    public void start() {
        LOG.info("{} start", getClass().getSimpleName());
        registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
    }

    @Override
    protected InstanceIdentifier<Node> getWildCardPath(){
        return InstanceIdentifier
                .create(NetworkTopology.class)
                .child(Topology.class,new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID))
                .child(Node.class);
    }

    @Override
    protected NeutronHostConfigChangeListener getDataTreeChangeListener() {
        return NeutronHostConfigChangeListener.this;
    }


    @Override
    protected void remove(InstanceIdentifier<Node>identifier, Node del){
        LOG.trace("NeutronHostConfigChangeListener.remove {}",del);
        updateHostConfig(del, Action.DELETE);
    }

    @Override
    protected void update(InstanceIdentifier<Node>identifier, Node original, Node update){
        LOG.trace("NeutronHostConfigChangeListener.update {}",update);
        updateHostConfig(update, Action.UPDATE);
    }

    @Override
    protected void add(InstanceIdentifier<Node>identifier, Node add){
        LOG.trace("NeutronHostConfigChangeListener.add {}",add);
        updateHostConfig(add, Action.ADD);

    }
<commit_msg>Do not log frequest NeutronHostConfig updates<commit_after>/*
 * Copyright (c) 2016 Intel Corporation.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.netvirt.neutronvpn;

import com.google.common.collect.Maps;
import java.util.Map;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.Hostconfigs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.Hostconfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.HostconfigBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIds;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class NeutronHostConfigChangeListener extends AsyncDataTreeChangeListenerBase<Node,
        NeutronHostConfigChangeListener> implements AutoCloseable {
    private static final Logger LOG = LoggerFactory.getLogger(NeutronHostConfigChangeListener.class);
    private final DataBroker dataBroker;
    private final SouthboundUtils southboundUtils;
    private final MdsalUtils mdsalUtils;
    private static final String OS_HOST_CONFIG_HOST_ID_KEY = "odl_os_hostconfig_hostid";
    private static final String OS_HOST_CONFIG_CONFIG_KEY_PREFIX = "odl_os_hostconfig_config_odl_";
    private static int HOST_TYPE_STR_LEN = 8;

    private enum Action {
        ADD,
        UPDATE,
        DELETE
    }

    public NeutronHostConfigChangeListener(final DataBroker dataBroker){
        super(Node.class,NeutronHostConfigChangeListener.class);
        this.dataBroker = dataBroker;
        this.mdsalUtils = new MdsalUtils(dataBroker);
        this.southboundUtils = new SouthboundUtils(mdsalUtils);
    }

    public void start() {
        LOG.info("{} start", getClass().getSimpleName());
        registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
    }

    @Override
    protected InstanceIdentifier<Node> getWildCardPath(){
        return InstanceIdentifier
                .create(NetworkTopology.class)
                .child(Topology.class,new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID))
                .child(Node.class);
    }

    @Override
    protected NeutronHostConfigChangeListener getDataTreeChangeListener() {
        return NeutronHostConfigChangeListener.this;
    }


    @Override
    protected void remove(InstanceIdentifier<Node>identifier, Node del){
        updateHostConfig(del, Action.DELETE);
    }

    @Override
    protected void update(InstanceIdentifier<Node>identifier, Node original, Node update){
        updateHostConfig(update, Action.UPDATE);
    }

    @Override
    protected void add(InstanceIdentifier<Node>identifier, Node add){
        updateHostConfig(add, Action.ADD);

    }

{'fraction_non_alphanumeric': 0.09313841075218109, 'fraction_numerical': 0.01909926904032068, 'mean_word_length': 4.603038309114927, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3147346', 'n_tokens_mistral': 2803, 'n_tokens_neox': 2642, 'n_words': 391}