Executes the CompareAndSet after merging changes @return True if the CAS was successful, false if the stored data was modified during flight.
(final ArrayList<KeyValue> row)
| 219 | * was modified during flight. |
| 220 | */ |
| 221 | @Override |
| 222 | public Deferred<Boolean> call(final ArrayList<KeyValue> row) |
| 223 | throws Exception { |
| 224 | |
| 225 | final UIDMeta stored_meta; |
| 226 | if (row == null || row.isEmpty()) { |
| 227 | stored_meta = null; |
| 228 | } else { |
| 229 | stored_meta = JSON.parseToObject(row.get(0).value(), UIDMeta.class); |
| 230 | stored_meta.initializeChangedMap(); |
| 231 | } |
| 232 | |
| 233 | final byte[] original_meta = row == null || row.isEmpty() ? |
| 234 | new byte[0] : row.get(0).value(); |
| 235 | |
| 236 | if (stored_meta != null) { |
| 237 | local_meta.syncMeta(stored_meta, overwrite); |
| 238 | } |
| 239 | |
| 240 | // verify the name is set locally just to be safe |
| 241 | if (name == null || name.isEmpty()) { |
| 242 | local_meta.name = name; |
| 243 | } |
| 244 | |
| 245 | final PutRequest put = new PutRequest(tsdb.uidTable(), |
| 246 | UniqueId.stringToUid(uid), FAMILY, |
| 247 | (type.toString().toLowerCase() + "_meta").getBytes(CHARSET), |
| 248 | local_meta.getStorageJSON()); |
| 249 | return tsdb.getClient().compareAndSet(put, original_meta); |
| 250 | } |
| 251 | |
| 252 | } |
| 253 |
nothing calls this directly
no test coverage detected