}
@Override
public MarshalledEntry<K, V> load(Object key) {
// TODO: a CLI command to retrieve value + metadata is needed
ProcessedCommand parsed = new ProcessedCommand("get " + key.toString() + ";");
// Having CLI context as field of this cache loader produces all sorts of
// issues when paralell requests are received, since the commands get
// bunched up. This is valid in shell mode, but a bit problematic for
// the cache loader. So, instead create a context instance for each
// operation. This is obviously not very efficient, but this cache loader
// should only be used during migration, so any inefficiencies should
// only be temporary.
Context cliCtx = createContext();
Command command = cliCtx.getCommandRegistry().getCommand(parsed.getCommand());
command.execute(cliCtx, parsed);
ResponseMatcher.Result result = ((ResponseMatcher) cliCtx.getOutputAdapter())
.getResult(Collections.singletonList(parsed));
if (result.isError)
throw new CacheException("Unable to load entry: " + result.result);