public void writeData(final String path, Object datat, final int expectedVersion) { writeDataReturnStat(path, datat, expectedVersion); }
ConditionalUpdateCallback customConditionCallback) { try { Stat stat = client.writeDataReturnStat(path, data, expectedVersion); log.debug( "Conditional update of path %s with value %s and expected version %d succeeded, returning the new version: %d"
/** * publish the version number of the next JobModel * @param oldVersion - used to validate, that no one has changed the version in the meanwhile. * @param newVersion - new version. */ public void publishJobModelVersion(String oldVersion, String newVersion) { Stat stat = new Stat(); String currentVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), stat); metrics.reads.inc(); LOG.info("publishing new version: " + newVersion + "; oldVersion = " + oldVersion + "(" + stat .getVersion() + ")"); if (currentVersion != null && !currentVersion.equals(oldVersion)) { throw new SamzaException( "Someone changed JobModelVersion while the leader was generating one: expected" + oldVersion + ", got " + currentVersion); } // data version is the ZK version of the data from the ZK. int dataVersion = stat.getVersion(); try { stat = zkClient.writeDataReturnStat(keyBuilder.getJobModelVersionPath(), newVersion, dataVersion); metrics.writes.inc(); } catch (Exception e) { String msg = "publish job model version failed for new version = " + newVersion + "; old version = " + oldVersion; LOG.error(msg, e); throw new SamzaException(msg, e); } LOG.info("published new version: " + newVersion + "; expected data version = " + (dataVersion + 1) + "(actual data version after update = " + stat.getVersion() + ")"); }
/** * publish the version number of the next JobModel * @param oldVersion - used to validate, that no one has changed the version in the meanwhile. * @param newVersion - new version. */ public void publishJobModelVersion(String oldVersion, String newVersion) { Stat stat = new Stat(); String currentVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), stat); metrics.reads.inc(); LOG.info("publishing new version: " + newVersion + "; oldVersion = " + oldVersion + "(" + stat .getVersion() + ")"); if (currentVersion != null && !currentVersion.equals(oldVersion)) { throw new SamzaException( "Someone changed JobModelVersion while the leader was generating one: expected" + oldVersion + ", got " + currentVersion); } // data version is the ZK version of the data from the ZK. int dataVersion = stat.getVersion(); try { stat = zkClient.writeDataReturnStat(keyBuilder.getJobModelVersionPath(), newVersion, dataVersion); metrics.writes.inc(); } catch (Exception e) { String msg = "publish job model version failed for new version = " + newVersion + "; old version = " + oldVersion; LOG.error(msg, e); throw new SamzaException(msg, e); } LOG.info("published new version: " + newVersion + "; expected data version = " + (dataVersion + 1) + "(actual data version after update = " + stat.getVersion() + ")"); }
/** * publish the version number of the next JobModel * @param oldVersion - used to validate, that no one has changed the version in the meanwhile. * @param newVersion - new version. */ public void publishJobModelVersion(String oldVersion, String newVersion) { Stat stat = new Stat(); String currentVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), stat); metrics.reads.inc(); LOG.info("publishing new version: " + newVersion + "; oldVersion = " + oldVersion + "(" + stat .getVersion() + ")"); if (currentVersion != null && !currentVersion.equals(oldVersion)) { throw new SamzaException( "Someone changed JobModelVersion while the leader was generating one: expected" + oldVersion + ", got " + currentVersion); } // data version is the ZK version of the data from the ZK. int dataVersion = stat.getVersion(); try { stat = zkClient.writeDataReturnStat(keyBuilder.getJobModelVersionPath(), newVersion, dataVersion); metrics.writes.inc(); } catch (Exception e) { String msg = "publish job model version failed for new version = " + newVersion + "; old version = " + oldVersion; LOG.error(msg, e); throw new SamzaException(msg, e); } LOG.info("published new version: " + newVersion + "; expected data version = " + (dataVersion + 1) + "(actual data version after update = " + stat.getVersion() + ")"); }
/** * publish the version number of the next JobModel * @param oldVersion - used to validate, that no one has changed the version in the meanwhile. * @param newVersion - new version. */ public void publishJobModelVersion(String oldVersion, String newVersion) { Stat stat = new Stat(); String currentVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), stat); metrics.reads.inc(); LOG.info("publishing new version: " + newVersion + "; oldVersion = " + oldVersion + "(" + stat .getVersion() + ")"); if (currentVersion != null && !currentVersion.equals(oldVersion)) { throw new SamzaException( "Someone changed JobModelVersion while the leader was generating one: expected" + oldVersion + ", got " + currentVersion); } // data version is the ZK version of the data from the ZK. int dataVersion = stat.getVersion(); try { stat = zkClient.writeDataReturnStat(keyBuilder.getJobModelVersionPath(), newVersion, dataVersion); metrics.writes.inc(); } catch (Exception e) { String msg = "publish job model version failed for new version = " + newVersion + "; old version = " + oldVersion; LOG.error(msg, e); throw new SamzaException(msg, e); } LOG.info("published new version: " + newVersion + "; expected data version = " + (dataVersion + 1) + "(actual data version after update = " + stat.getVersion() + ")"); }
/** * publish the version number of the next JobModel * @param oldVersion - used to validate, that no one has changed the version in the meanwhile. * @param newVersion - new version. */ public void publishJobModelVersion(String oldVersion, String newVersion) { Stat stat = new Stat(); String currentVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), stat); metrics.reads.inc(); LOG.info("publishing new version: " + newVersion + "; oldVersion = " + oldVersion + "(" + stat .getVersion() + ")"); if (currentVersion != null && !currentVersion.equals(oldVersion)) { throw new SamzaException( "Someone changed JobModelVersion while the leader was generating one: expected" + oldVersion + ", got " + currentVersion); } // data version is the ZK version of the data from the ZK. int dataVersion = stat.getVersion(); try { stat = zkClient.writeDataReturnStat(keyBuilder.getJobModelVersionPath(), newVersion, dataVersion); metrics.writes.inc(); } catch (Exception e) { String msg = "publish job model version failed for new version = " + newVersion + "; old version = " + oldVersion; LOG.error(msg, e); throw new SamzaException(msg, e); } LOG.info("published new version: " + newVersion + "; expected data version = " + (dataVersion + 1) + "(actual data version after update = " + stat.getVersion() + ")"); }