Example usage for java.util.concurrent.atomic AtomicReference set

List of usage examples for java.util.concurrent.atomic AtomicReference set

Introduction

In this page you can find the example usage for java.util.concurrent.atomic AtomicReference set.

Prototype

public final void set(V newValue) 

Source Link

Document

Sets the value to newValue , with memory effects as specified by VarHandle#setVolatile .

Usage

From source file:org.apache.nifi.provenance.MiNiFiPersistentProvenanceRepository.java

/**
 * <p>/*from  ww  w .ja  v  a2s.  co  m*/
 * MUST be called with the write lock held.
 * </p>
 * <p>
 * Rolls over the data in the journal files, merging them into a single Provenance Event Log File, and
 * compressing as needed.
 *
 * @param force if true, will force a rollover regardless of whether or not data has been written
 * @throws IOException if unable to complete rollover
 */
private void rollover(final boolean force) throws IOException {
    if (!configuration.isAllowRollover()) {
        return;
    }

    // If this is the first time we're creating the out stream, or if we
    // have written something to the stream, then roll over
    if (force || recordsWrittenSinceRollover.get() > 0L || dirtyWriterCount.get() > 0) {
        final List<File> journalsToMerge = new ArrayList<>();
        for (final RecordWriter writer : writers) {
            if (!writer.isClosed()) {
                final File writerFile = writer.getFile();
                journalsToMerge.add(writerFile);
                try {
                    writer.close();
                } catch (final IOException ioe) {
                    logger.warn("Failed to close {} due to {}", writer, ioe.toString());
                    if (logger.isDebugEnabled()) {
                        logger.warn("", ioe);
                    }
                }
            }
        }

        if (logger.isDebugEnabled()) {
            if (journalsToMerge.isEmpty()) {
                logger.debug("No journals to merge; all RecordWriters were already closed");
            } else {
                logger.debug("Going to merge {} files for journals starting with ID {}", journalsToMerge.size(),
                        StringUtils.substringBefore(journalsToMerge.get(0).getName(), "."));
            }
        }

        // Choose a storage directory to store the merged file in.
        final long storageDirIdx = storageDirectoryIndex.getAndIncrement();
        final List<File> storageDirs = configuration.getStorageDirectories();
        final File storageDir = storageDirs.get((int) (storageDirIdx % storageDirs.size()));

        Future<?> future = null;
        if (!journalsToMerge.isEmpty()) {
            // Run the rollover logic in a background thread.
            final AtomicReference<Future<?>> futureReference = new AtomicReference<>();
            final int recordsWritten = recordsWrittenSinceRollover.getAndSet(0);
            final Runnable rolloverRunnable = new Runnable() {
                @Override
                public void run() {
                    try {
                        final File fileRolledOver;

                        try {
                            fileRolledOver = mergeJournals(journalsToMerge,
                                    getMergeFile(journalsToMerge, storageDir), eventReporter);
                        } catch (final IOException ioe) {
                            logger.error(
                                    "Failed to merge Journal Files {} into a Provenance Log File due to {}",
                                    journalsToMerge, ioe.toString());
                            logger.error("", ioe);
                            return;
                        }

                        if (fileRolledOver == null) {
                            logger.debug(
                                    "Couldn't merge journals. Will try again in 10 seconds. journalsToMerge: {}, storageDir: {}",
                                    journalsToMerge, storageDir);
                            return;
                        }
                        final File file = fileRolledOver;

                        // update our map of id to Path
                        // We need to make sure that another thread doesn't also update the map at the same time. We cannot
                        // use the write lock when purging old events, and we want to use the same approach here.
                        boolean updated = false;
                        final Long fileFirstEventId = Long
                                .valueOf(StringUtils.substringBefore(fileRolledOver.getName(), "."));
                        while (!updated) {
                            final SortedMap<Long, Path> existingPathMap = idToPathMap.get();
                            final SortedMap<Long, Path> newIdToPathMap = new TreeMap<>(new PathMapComparator());
                            newIdToPathMap.putAll(existingPathMap);
                            newIdToPathMap.put(fileFirstEventId, file.toPath());
                            updated = idToPathMap.compareAndSet(existingPathMap, newIdToPathMap);
                        }

                        logger.info("Successfully Rolled over Provenance Event file containing {} records",
                                recordsWritten);
                        rolloverCompletions.getAndIncrement();

                        // We have finished successfully. Cancel the future so that we don't run anymore
                        Future<?> future;
                        while ((future = futureReference.get()) == null) {
                            try {
                                Thread.sleep(10L);
                            } catch (final InterruptedException ie) {
                            }
                        }

                        future.cancel(false);
                    } catch (final Throwable t) {
                        logger.error("Failed to rollover Provenance repository due to {}", t.toString());
                        logger.error("", t);
                    }
                }
            };

            // We are going to schedule the future to run immediately and then repeat every 10 seconds. This allows us to keep retrying if we
            // fail for some reason. When we succeed, the Runnable will cancel itself.
            future = rolloverExecutor.scheduleWithFixedDelay(rolloverRunnable, 0, 10, TimeUnit.SECONDS);
            futureReference.set(future);
        }

        streamStartTime.set(System.currentTimeMillis());
        bytesWrittenSinceRollover.set(0);

        // We don't want to create new 'writers' until the number of unmerged journals falls below our threshold. So we wait
        // here before we repopulate the 'writers' member variable and release the lock.
        int journalFileCount = getJournalCount();
        long repoSize = getSize(getLogFiles(), 0L);
        final int journalCountThreshold = configuration.getJournalCount() * 5;
        final long sizeThreshold = (long) (configuration.getMaxStorageCapacity() * 1.1D); // do not go over 10% of max capacity

        // check if we need to apply backpressure.
        // If we have too many journal files, or if the repo becomes too large, backpressure is necessary. Without it,
        // if the rate at which provenance events are registered exceeds the rate at which we can compress/merge them,
        // then eventually we will end up with all of the data stored in the 'journals' directory. This
        // would mean that the data would never even be accessible. In order to prevent this, if we exceeds 110% of the configured
        // max capacity for the repo, or if we have 5 sets of journal files waiting to be merged, we will block here until
        // that is no longer the case.
        if (journalFileCount > journalCountThreshold || repoSize > sizeThreshold) {
            logger.warn("The rate of the dataflow is exceeding the provenance recording rate. "
                    + "Slowing down flow to accommodate. Currently, there are {} journal files ({} bytes) and "
                    + "threshold for blocking is {} ({} bytes)", journalFileCount, repoSize,
                    journalCountThreshold, sizeThreshold);
            eventReporter.reportEvent(Severity.WARNING, "Provenance Repository", "The rate of the dataflow is "
                    + "exceeding the provenance recording rate. Slowing down flow to accommodate");

            while (journalFileCount > journalCountThreshold || repoSize > sizeThreshold) {
                // if a shutdown happens while we are in this loop, kill the rollover thread and break
                if (this.closed.get()) {
                    if (future != null) {
                        future.cancel(true);
                    }

                    break;
                }

                if (repoSize > sizeThreshold) {
                    logger.debug(
                            "Provenance Repository has exceeded its size threshold; will trigger purging of oldest events");
                    purgeOldEvents();

                    journalFileCount = getJournalCount();
                    repoSize = getSize(getLogFiles(), 0L);
                    continue;
                } else {
                    // if we are constrained by the number of journal files rather than the size of the repo,
                    // then we will just sleep a bit because another thread is already actively merging the journals,
                    // due to the runnable that we scheduled above
                    try {
                        Thread.sleep(100L);
                    } catch (final InterruptedException ie) {
                    }
                }

                logger.debug(
                        "Provenance Repository is still behind. Keeping flow slowed down "
                                + "to accommodate. Currently, there are {} journal files ({} bytes) and "
                                + "threshold for blocking is {} ({} bytes)",
                        journalFileCount, repoSize, journalCountThreshold, sizeThreshold);

                journalFileCount = getJournalCount();
                repoSize = getSize(getLogFiles(), 0L);
            }

            logger.info(
                    "Provenance Repository has now caught up with rolling over journal files. Current number of "
                            + "journal files to be rolled over is {}",
                    journalFileCount);
        }

        // we've finished rolling over successfully. Create new writers and reset state.
        writers = createWriters(configuration, idGenerator.get());
        dirtyWriterCount.set(0);
        streamStartTime.set(System.currentTimeMillis());
        recordsWrittenSinceRollover.getAndSet(0);
    }
}

From source file:cl.gisred.android.RegEquipoActivity.java

private void cerrarDialogCrear(boolean bSave, @Nullable View viewDialog) {
    final AtomicReference<String> resp = new AtomicReference<>("");

    if (bSave) {// w w  w .j  a  v  a 2 s  .  c  om
        if (!validarVista(viewDialog)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {
            switch (idResLayoutSelect) {
            case R.layout.dialog_poste:
                oLyAddGraphs = LyAddPoste;
                break;
            case R.layout.dialog_direccion:
                oLyAddGraphs = LyAddDireccion;
                break;
            case R.layout.dialog_cliente:
                oLyAddGraphs = LyAddCliente;
                break;
            case R.layout.dialog_cliente_cnr:
                oLyAddGraphs = LyAddClienteCnr;
                break;
            }

            if (oLyAddGraphs != null) {
                View oView = getLayoutValidate(viewDialog);
                Util oUtil = new Util(oUbicacion);

                ArrayList<Map<String, Object>> oAttrToSave = oUtil.getAttrAddByView(oView, idResLayoutSelect,
                        empresa);

                Map<String, Object> attributes = oAttrToSave.get(0);
                Graphic newFeatureGraphic = new Graphic(oUbicacion, null, attributes);
                Graphic[] adds = { newFeatureGraphic };

                if (idResLayoutSelect == R.layout.dialog_cliente_cnr
                        || idResLayoutSelect == R.layout.dialog_cliente) {
                    addsUnion = Util.addAttrUnionPoint(oAttrToSave, oUbicacion);
                }

                oLyAddGraphs.applyEdits(adds, null, null, new CallbackListener<FeatureEditResult[][]>() {

                    @Override
                    public void onCallback(FeatureEditResult[][] featureEditResults) {
                        if (featureEditResults[0] != null) {
                            if (featureEditResults[0][0] != null && featureEditResults[0][0].isSuccess()) {

                                resp.set(
                                        "Guardado Correctamente Id: " + featureEditResults[0][0].getObjectId());

                                if (idResLayoutSelect == R.layout.dialog_cliente_cnr
                                        || idResLayoutSelect == R.layout.dialog_cliente)
                                    LyAddUnion.applyEdits(addsUnion, null, null, callBackUnion());

                                runOnUiThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        Util.showConfirmation(RegEquipoActivity.this, resp.get());
                                    }
                                });
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable throwable) {
                        resp.set("Error al grabar: " + throwable.getLocalizedMessage());
                        Log.w("onError", resp.get());

                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                Toast.makeText(RegEquipoActivity.this, resp.get(), Toast.LENGTH_SHORT).show();
                            }
                        });
                    }

                });
            }
        }
    } else {
        resp.set("Cancelado");
        Toast.makeText(RegEquipoActivity.this, resp.get(), Toast.LENGTH_LONG).show();
    }

    bMapTap = false;

    if (mBusquedaLayer != null && myMapView.getLayerByID(mBusquedaLayer.getID()) != null)
        myMapView.removeLayer(mBusquedaLayer);

    if (mUbicacionLayer != null && myMapView.getLayerByID(mUbicacionLayer.getID()) != null)
        myMapView.removeLayer(mUbicacionLayer);

    if (mSeleccionLayer != null && myMapView.getLayerByID(mSeleccionLayer.getID()) != null)
        myMapView.removeLayer(mSeleccionLayer);

    oUbicacion = null;
    if (bVerCapas)
        toogleCapas(fabVerCapas);
    //setLayerAddToggle(false);
    if (bIngCliente)
        menuMultipleActions.setVisibility(View.VISIBLE);
    menuMicroActions.setVisibility(View.VISIBLE);
    fabShowDialog.setVisibility(View.GONE);
    dialogCrear.dismiss();
    if (oLyAddGraphs != null)
        oLyAddGraphs.setVisible(true);
}

From source file:cl.gisred.android.MicroMedidaActivity.java

private void cerrarDialogCrear(boolean bSave, @Nullable View viewDialog) {
    final AtomicReference<String> resp = new AtomicReference<>("");

    if (bSave) {//from   www.j  a  va2  s.  c o m
        if (!validarVista(viewDialog)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {
            switch (idResLayoutSelect) {
            case R.layout.dialog_poste:
                oLyAddGraphs = LyAddPoste;
                break;
            case R.layout.dialog_direccion:
                oLyAddGraphs = LyAddDireccion;
                break;
            case R.layout.dialog_cliente:
                oLyAddGraphs = LyAddCliente;
                break;
            case R.layout.dialog_cliente_cnr:
                oLyAddGraphs = LyAddClienteCnr;
                break;
            }

            if (oLyAddGraphs != null) {
                View oView = getLayoutValidate(viewDialog);
                Util oUtil = new Util(oUbicacion);

                ArrayList<Map<String, Object>> oAttrToSave = oUtil.getAttrAddByView(oView, idResLayoutSelect,
                        empresa);

                Map<String, Object> attributes = oAttrToSave.get(0);
                Graphic newFeatureGraphic = new Graphic(oUbicacion, null, attributes);
                Graphic[] adds = { newFeatureGraphic };

                if (idResLayoutSelect == R.layout.dialog_cliente_cnr
                        || idResLayoutSelect == R.layout.dialog_cliente) {
                    addsUnion = Util.addAttrUnionPoint(oAttrToSave, oUbicacion);
                }

                oLyAddGraphs.applyEdits(adds, null, null, new CallbackListener<FeatureEditResult[][]>() {

                    @Override
                    public void onCallback(FeatureEditResult[][] featureEditResults) {
                        if (featureEditResults[0] != null) {
                            if (featureEditResults[0][0] != null && featureEditResults[0][0].isSuccess()) {

                                resp.set(
                                        "Guardado Correctamente Id: " + featureEditResults[0][0].getObjectId());

                                if (idResLayoutSelect == R.layout.dialog_cliente_cnr
                                        || idResLayoutSelect == R.layout.dialog_cliente)
                                    LyAddUnion.applyEdits(addsUnion, null, null, callBackUnion());

                                runOnUiThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        Util.showConfirmation(MicroMedidaActivity.this, resp.get());
                                    }
                                });
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable throwable) {
                        resp.set("Error al grabar: " + throwable.getLocalizedMessage());
                        Log.w("onError", resp.get());

                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                Toast.makeText(MicroMedidaActivity.this, resp.get(), Toast.LENGTH_SHORT).show();
                            }
                        });
                    }

                });
            }
        }
    } else {
        resp.set("Cancelado");
        Toast.makeText(MicroMedidaActivity.this, resp.get(), Toast.LENGTH_LONG).show();
    }

    bMapTap = false;

    if (mBusquedaLayer != null && myMapView.getLayerByID(mBusquedaLayer.getID()) != null)
        myMapView.removeLayer(mBusquedaLayer);

    if (mUbicacionLayer != null && myMapView.getLayerByID(mUbicacionLayer.getID()) != null)
        myMapView.removeLayer(mUbicacionLayer);

    if (mSeleccionLayer != null && myMapView.getLayerByID(mSeleccionLayer.getID()) != null)
        myMapView.removeLayer(mSeleccionLayer);

    oUbicacion = null;
    if (bVerCapas)
        toogleCapas(fabVerCapas);
    //setLayerAddToggle(false);
    if (bIngCliente)
        menuMultipleActions.setVisibility(View.VISIBLE);
    menuMicroActions.setVisibility(View.VISIBLE);
    fabShowDialog.setVisibility(View.GONE);
    dialogCrear.dismiss();
    if (oLyAddGraphs != null)
        oLyAddGraphs.setVisible(true);
}

From source file:com.microsoft.tfs.core.clients.versioncontrol.VersionControlClient.java

/**
 * @see #determineWorkspaceNameAndOwner(ItemSpec[], AtomicReference<String>,
 *      AtomicReference<String>)/*from   w  w w  .  j ava2 s .  c o  m*/
 */
public void determineWorkspaceNameAndOwner(final String[] paths, final AtomicReference<String> workspaceName,
        final AtomicReference<String> workspaceOwner) {
    if (paths == null) {
        workspaceName.set(null);
        workspaceOwner.set(null);
    } else {
        determineWorkspaceNameAndOwner(ItemSpec.fromStrings(paths, RecursionType.NONE), workspaceName,
                workspaceOwner);
    }
}

From source file:com.microsoft.tfs.core.clients.versioncontrol.VersionControlClient.java

/**
 * @see #determineWorkspaceNameAndOwner(ItemSpec[], AtomicReference<String>,
 *      AtomicReference<String>)//from w ww  .jav a 2  s  . co m
 */
public void determineWorkspaceNameAndOwner(final LabelItemSpec[] labelItemSpecs,
        final AtomicReference<String> workspaceName, final AtomicReference<String> workspaceOwner) {
    if (labelItemSpecs == null) {
        workspaceName.set(null);
        workspaceOwner.set(null);
    } else {
        final ItemSpec[] itemSpecs = new ItemSpec[labelItemSpecs.length];
        for (int i = 0; i < itemSpecs.length; i++) {
            itemSpecs[i] = labelItemSpecs[i].getItemSpec();
        }

        determineWorkspaceNameAndOwner(itemSpecs, workspaceName, workspaceOwner);
    }
}

From source file:com.microsoft.tfs.core.clients.versioncontrol.VersionControlClient.java

/**
 * @see #determineWorkspaceNameAndOwner(ItemSpec[], AtomicReference<String>,
 *      AtomicReference<String>)/*from  w  ww .ja v  a2s  .com*/
 */
public void determineWorkspaceNameAndOwner(final ItemSpec itemSpec, final AtomicReference<String> workspaceName,
        final AtomicReference<String> workspaceOwner) {
    if (itemSpec == null) {
        workspaceName.set(null);
        workspaceOwner.set(null);
    } else {
        determineWorkspaceNameAndOwner(new ItemSpec[] { itemSpec }, workspaceName, workspaceOwner);
    }
}

From source file:com.microsoft.tfs.core.clients.versioncontrol.VersionControlClient.java

/**
 * @see #determineWorkspaceNameAndOwner(ItemSpec[], AtomicReference<String>,
 *      AtomicReference<String>)//from ww  w . j a  v a 2  s  . c o  m
 */
public void determineWorkspaceNameAndOwner(final SecurityChange[] securityChanges,
        final AtomicReference<String> workspaceName, final AtomicReference<String> workspaceOwner) {
    if (securityChanges == null) {
        workspaceName.set(null);
        workspaceOwner.set(null);
    } else {
        final ItemSpec[] itemSpecs = new ItemSpec[securityChanges.length];
        for (int i = 0; i < itemSpecs.length; i++) {
            itemSpecs[i] = new ItemSpec(securityChanges[i].getItem(), RecursionType.NONE);
        }

        determineWorkspaceNameAndOwner(itemSpecs, workspaceName, workspaceOwner);
    }
}

From source file:com.microsoft.tfs.core.clients.versioncontrol.VersionControlClient.java

/**
 * Determine the workspace name and owner for all given items which are
 * local paths. Throws if any two paths are in different workspaces. Does
 * not throw if no workspace was found ({@link AtomicReference<String>}
 * values are set to <code>null</code>).
 *
 * @param itemSpecs/*from  w ww.  java 2s .  c om*/
 *        the {@link ItemSpec}s to determine name and owner for (if
 *        <code>null</code>, both {@link AtomicReference<String>} values are
 *        set to <code>null</code>)
 * @param workspaceName
 *        the {@link AtomicReference<String>} to update with the workspace
 *        name (must not be <code>null</code>)
 * @param workspaceOwner
 *        the {@link AtomicReference<String>} to update with the workspace
 *        owner (must not be <code>null</code>)
 * @throws OnlyOneWorkspaceException
 *         if any two paths are in different workspaces
 */
public void determineWorkspaceNameAndOwner(final ItemSpec[] itemSpecs,
        final AtomicReference<String> workspaceName, final AtomicReference<String> workspaceOwner) {
    if (itemSpecs == null) {
        workspaceName.set(null);
        workspaceOwner.set(null);
    } else {
        Workspace workspace = null;

        for (int i = 0; i < itemSpecs.length; i++) {
            final ItemSpec spec = itemSpecs[i];

            if (ServerPath.isServerPath(spec.getItem()) == false) {
                final Workspace itemWorkspace = getWorkspace(spec.getItem());

                if (workspace == null) {
                    workspace = itemWorkspace;
                } else if (workspace.equals(itemWorkspace) == false) {
                    throw new OnlyOneWorkspaceException(itemWorkspace, spec.getItem());
                }
            }
        }

        if (workspace == null) {
            workspaceName.set(null);
            workspaceOwner.set(null);
        } else {
            workspaceName.set(workspace.getName());
            workspaceOwner.set(workspace.getOwnerName());
        }
    }
}

From source file:com.microsoft.tfs.core.clients.versioncontrol.VersionControlClient.java

/**
 * @see #determineWorkspaceNameAndOwner(ItemSpec[], AtomicReference<String>,
 *      AtomicReference<String>)/*from www .j a  va2  s  .  c  om*/
 */
public void determineWorkspaceNameAndOwner(final String path, final AtomicReference<String> workspaceName,
        final AtomicReference<String> workspaceOwner) {
    if (path == null || path.length() == 0) {
        workspaceName.set(null);
        workspaceOwner.set(null);
    } else {
        determineWorkspaceNameAndOwner(new ItemSpec(path, RecursionType.NONE), workspaceName, workspaceOwner);
    }
}

From source file:de.schildbach.pte.AbstractEfaProvider.java

protected NearbyLocationsResult mobileCoordRequest(final EnumSet<LocationType> types, final int lat,
        final int lon, final int maxDistance, final int maxStations) throws IOException {
    final HttpUrl.Builder url = coordEndpoint.newBuilder();
    appendXmlCoordRequestParameters(url, types, lat, lon, maxDistance, maxStations);
    final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();

    final HttpClient.Callback callback = new HttpClient.Callback() {
        @Override/*from w w w  . j a v a  2  s .  com*/
        public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
            try {
                final XmlPullParser pp = parserFactory.newPullParser();
                pp.setInput(body.byteStream(), null); // Read encoding from XML declaration
                final ResultHeader header = enterEfa(pp);

                XmlPullUtil.enter(pp, "ci");

                XmlPullUtil.enter(pp, "request");
                XmlPullUtil.skipExit(pp, "request");

                final List<Location> stations = new ArrayList<>();

                if (XmlPullUtil.optEnter(pp, "pis")) {
                    while (XmlPullUtil.optEnter(pp, "pi")) {
                        final String name = normalizeLocationName(XmlPullUtil.optValueTag(pp, "de", null));
                        final String type = XmlPullUtil.valueTag(pp, "ty");
                        final LocationType locationType;
                        if ("STOP".equals(type))
                            locationType = LocationType.STATION;
                        else if ("POI_POINT".equals(type))
                            locationType = LocationType.POI;
                        else
                            throw new IllegalStateException("unknown type: " + type);

                        final String id = XmlPullUtil.valueTag(pp, "id");
                        XmlPullUtil.valueTag(pp, "omc");
                        XmlPullUtil.optValueTag(pp, "pid", null);
                        final String place = normalizeLocationName(XmlPullUtil.valueTag(pp, "locality"));
                        XmlPullUtil.valueTag(pp, "layer");
                        XmlPullUtil.valueTag(pp, "gisID");
                        XmlPullUtil.valueTag(pp, "ds");
                        XmlPullUtil.valueTag(pp, "stateless");
                        final Point coord = parseCoord(XmlPullUtil.valueTag(pp, "c"));

                        final Location location;
                        if (name != null)
                            location = new Location(locationType, id, coord, place, name);
                        else
                            location = new Location(locationType, id, coord, null, place);
                        stations.add(location);

                        XmlPullUtil.skipExit(pp, "pi");
                    }

                    XmlPullUtil.skipExit(pp, "pis");
                }

                XmlPullUtil.skipExit(pp, "ci");

                result.set(new NearbyLocationsResult(header, stations));
            } catch (final XmlPullParserException x) {
                throw new ParserException("cannot parse xml: " + bodyPeek, x);
            }
        }
    };

    if (httpPost)
        httpClient.getInputStream(callback, url.build(), url.build().encodedQuery(),
                "application/x-www-form-urlencoded", httpReferer);
    else
        httpClient.getInputStream(callback, url.build(), httpReferer);

    return result.get();
}