private static URI buildUri(String rrdPath, URI rrdUri, RrdBackendFactory factory) { if (rrdUri != null) { return rrdUri; } else if (factory == null) { return RrdBackendFactory.buildGenericUri(rrdPath); } else { return factory.getCanonicalUri(RrdBackendFactory.buildGenericUri(rrdPath)); } }
private RrdDb requestRrdDb(RrdDb.Builder builder, URI uri, RrdBackendFactory backend) throws IOException { RrdEntry ref = null; uri = backend.getCanonicalUri(uri); try { ref = requestEmpty(uri); ref.rrdDb = builder.setPath(uri).setBackendFactory(backend).setPool(this).build(); return ref.rrdDb; } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException("request interrupted for new rrd " + uri, e); } catch (RuntimeException e) { passNext(ACTION.DROP, ref); ref = null; throw e; } finally { if (ref != null) { passNext(ACTION.SWAP, ref); } } }
RrdDb requestRrdDb(URI uri, RrdBackendFactory factory) throws IOException { uri = factory.getCanonicalUri(uri); RrdEntry ref = null; try { ref = getEntry(uri, true); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IllegalStateException("request interrupted for " + uri, e); } //Someone might have already open it, rechecks if (ref.count == 0) { try { ref.rrdDb = RrdDb.getBuilder().setPath(factory.getPath(uri)).setBackendFactory(factory).setPool(this).build(); } catch (IOException | RuntimeException e) { passNext(ACTION.DROP, ref); throw e; } } ref.count++; passNext(ACTION.SWAP, ref); return ref.rrdDb; }
RrdDb requestRrdDb(RrdDef rrdDef, RrdBackendFactory backend) throws IOException { RrdEntry ref = null; try { URI uri = backend.getCanonicalUri(rrdDef.getUri()); ref = requestEmpty(uri); ref.rrdDb = RrdDb.getBuilder().setRrdDef(rrdDef).setBackendFactory(backend).setPool(this).build(); return ref.rrdDb; } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException("request interrupted for new rrdDef " + rrdDef.getPath(), e); } catch (RuntimeException e) { passNext(ACTION.DROP, ref); ref = null; throw e; } finally { if (ref != null) { passNext(ACTION.SWAP, ref); } } }
URI rrdUri = buildUri(path, uri, factory); factory = checkFactory(rrdUri, factory); rrdUri = factory.getCanonicalUri(rrdUri); if (!factory.canStore(rrdUri)) { throw new IllegalArgumentException("Given a factory incompatible with the URI");