Search in sources :

Example 1 with CarPersonKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.car.people.CarPersonKey in project controller by opendaylight.

the class PeopleCarListener method onCarBought.

@Override
public void onCarBought(CarBought notification) {
    final CarPersonBuilder carPersonBuilder = new CarPersonBuilder();
    carPersonBuilder.setCarId(notification.getCarId());
    carPersonBuilder.setPersonId(notification.getPersonId());
    CarPersonKey key = new CarPersonKey(notification.getCarId(), notification.getPersonId());
    carPersonBuilder.setKey(key);
    final CarPerson carPerson = carPersonBuilder.build();
    LOG.info("Car bought, adding car-person entry: [{}]", carPerson);
    InstanceIdentifier<CarPerson> carPersonIId = InstanceIdentifier.<CarPeople>builder(CarPeople.class).child(CarPerson.class, carPerson.getKey()).build();
    WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
    tx.put(LogicalDatastoreType.CONFIGURATION, carPersonIId, carPerson, true);
    Futures.addCallback(tx.submit(), new FutureCallback<Void>() {

        @Override
        public void onSuccess(final Void result) {
            LOG.info("Successfully added car-person entry: [{}]", carPerson);
        }

        @Override
        public void onFailure(final Throwable ex) {
            LOG.error(String.format("Failed to add car-person entry: [%s]", carPerson), ex);
        }
    }, MoreExecutors.directExecutor());
}
Also used : CarPersonKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.car.people.CarPersonKey) CarPerson(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.car.people.CarPerson) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) CarPersonBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.car.people.CarPersonBuilder) CarPeople(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.CarPeople)

Aggregations

WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 CarPeople (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.CarPeople)1 CarPerson (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.car.people.CarPerson)1 CarPersonBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.car.people.CarPersonBuilder)1 CarPersonKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.car.people.CarPersonKey)1