use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.CarPeople 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());
}
Aggregations