Example usage for java.lang IllegalStateException getMessage

List of usage examples for java.lang IllegalStateException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalStateException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java

public void removeMember(Command command) {
    if (command != null && command instanceof StringType) {
        try {//from  w  w  w. j  a  v  a2s. c  om
            ZonePlayerHandler oldmemberHandler = getHandlerByName(command.toString());

            oldmemberHandler.becomeStandAlonePlayer();
            SonosEntry entry = new SonosEntry("", "", "", "", "", "", "",
                    QUEUE_URI + oldmemberHandler.getUDN() + "#0");
            oldmemberHandler.setCurrentURI(entry);
        } catch (IllegalStateException e) {
            logger.warn("Cannot remove group member ({})", e.getMessage());
        }
    }
}

From source file:org.apache.accumulo.tserver.tablet.Tablet.java

public TreeMap<KeyExtent, TabletData> split(byte[] sp) throws IOException {

    if (sp != null && extent.getEndRow() != null && extent.getEndRow().equals(new Text(sp))) {
        throw new IllegalArgumentException();
    }//from   w ww  .  jav a 2  s . c o m

    if (sp != null && sp.length > tableConfiguration.getMemoryInBytes(Property.TABLE_MAX_END_ROW_SIZE)) {
        String msg = "Cannot split tablet " + extent + ", selected split point too long.  Length :  "
                + sp.length;
        log.warn(msg);
        throw new IOException(msg);
    }

    if (extent.isRootTablet()) {
        String msg = "Cannot split root tablet";
        log.warn(msg);
        throw new RuntimeException(msg);
    }

    try {
        initiateClose(true, false, false);
    } catch (IllegalStateException ise) {
        log.debug("File " + extent + " not splitting : " + ise.getMessage());
        return null;
    }

    // obtain this info outside of synch block since it will involve opening
    // the map files... it is ok if the set of map files changes, because
    // this info is used for optimization... it is ok if map files are missing
    // from the set... can still query and insert into the tablet while this
    // map file operation is happening
    Map<FileRef, FileUtil.FileInfo> firstAndLastRows = FileUtil.tryToGetFirstAndLastRows(
            getTabletServer().getFileSystem(), getTabletServer().getConfiguration(),
            getDatafileManager().getFiles());

    synchronized (this) {
        // java needs tuples ...
        TreeMap<KeyExtent, TabletData> newTablets = new TreeMap<KeyExtent, TabletData>();

        long t1 = System.currentTimeMillis();
        // choose a split point
        SplitRowSpec splitPoint;
        if (sp == null)
            splitPoint = findSplitRow(getDatafileManager().getFiles());
        else {
            Text tsp = new Text(sp);
            splitPoint = new SplitRowSpec(FileUtil.estimatePercentageLTE(getTabletServer().getFileSystem(),
                    getTabletServer().getConfiguration(), extent.getPrevEndRow(), extent.getEndRow(),
                    FileUtil.toPathStrings(getDatafileManager().getFiles()), tsp), tsp);
        }

        if (splitPoint == null || splitPoint.row == null) {
            log.info("had to abort split because splitRow was null");
            closeState = CloseState.OPEN;
            return null;
        }

        closeState = CloseState.CLOSING;
        completeClose(true, false);

        Text midRow = splitPoint.row;
        double splitRatio = splitPoint.splitRatio;

        KeyExtent low = new KeyExtent(extent.getTableId(), midRow, extent.getPrevEndRow());
        KeyExtent high = new KeyExtent(extent.getTableId(), extent.getEndRow(), midRow);

        String lowDirectory = createTabletDirectory(getTabletServer().getFileSystem(), extent.getTableId(),
                midRow);

        // write new tablet information to MetadataTable
        SortedMap<FileRef, DataFileValue> lowDatafileSizes = new TreeMap<FileRef, DataFileValue>();
        SortedMap<FileRef, DataFileValue> highDatafileSizes = new TreeMap<FileRef, DataFileValue>();
        List<FileRef> highDatafilesToRemove = new ArrayList<FileRef>();

        MetadataTableUtil.splitDatafiles(extent.getTableId(), midRow, splitRatio, firstAndLastRows,
                getDatafileManager().getDatafileSizes(), lowDatafileSizes, highDatafileSizes,
                highDatafilesToRemove);

        log.debug("Files for low split " + low + "  " + lowDatafileSizes.keySet());
        log.debug("Files for high split " + high + "  " + highDatafileSizes.keySet());

        String time = tabletTime.getMetadataValue();

        MetadataTableUtil.splitTablet(high, extent.getPrevEndRow(), splitRatio, getTabletServer(),
                getTabletServer().getLock());
        MasterMetadataUtil.addNewTablet(getTabletServer(), low, lowDirectory,
                getTabletServer().getTabletSession(), lowDatafileSizes, getBulkIngestedFiles(), time,
                lastFlushID, lastCompactID, getTabletServer().getLock());
        MetadataTableUtil.finishSplit(high, highDatafileSizes, highDatafilesToRemove, getTabletServer(),
                getTabletServer().getLock());

        log.log(TLevel.TABLET_HIST, extent + " split " + low + " " + high);

        newTablets.put(high, new TabletData(tabletDirectory, highDatafileSizes, time, lastFlushID,
                lastCompactID, lastLocation, getBulkIngestedFiles()));
        newTablets.put(low, new TabletData(lowDirectory, lowDatafileSizes, time, lastFlushID, lastCompactID,
                lastLocation, getBulkIngestedFiles()));

        long t2 = System.currentTimeMillis();

        log.debug(String.format("offline split time : %6.2f secs", (t2 - t1) / 1000.0));

        closeState = CloseState.COMPLETE;
        return newTablets;
    }
}

From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java

public void playTrack(Command command) {

    if (command != null && command instanceof DecimalType) {
        try {//w  w w.  ja  v  a 2s  .c o m
            ZonePlayerHandler coordinator = getCoordinatorHandler();

            String trackNumber = command.toString();

            coordinator.setCurrentURI(QUEUE_URI + coordinator.getUDN() + "#0", "");

            // seek the track - warning, we do not check if the tracknumber falls in the boundary of the queue
            coordinator.setPositionTrack(trackNumber);

            // take the system off mute
            coordinator.setMute(OnOffType.OFF);

            // start jammin'
            coordinator.play();
        } catch (IllegalStateException e) {
            logger.warn("Cannot play track ({})", e.getMessage());
        }
    }

}

From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java

/**
 * Play a given notification sound/*from   w  w w.  j  a v a2s .c o  m*/
 *
 * @param url in the format of //host/folder/filename.mp3
 */
public void playNotificationSoundURI(Command notificationURL) {

    if (notificationURL != null && notificationURL instanceof StringType) {
        try {
            ZonePlayerHandler coordinator = getCoordinatorHandler();

            String currentURI = coordinator.getCurrentURI();

            if (isPlayingStream(currentURI)) {
                handleRadioStream(currentURI, notificationURL, coordinator);
            } else if (isPlayingLineIn(currentURI)) {
                handleLineIn(currentURI, notificationURL, coordinator);
            } else if (isPlayingQueue(currentURI)) {
                handleSharedQueue(notificationURL, coordinator);
            } else if (isPlaylistEmpty(coordinator)) {
                handleEmptyQueue(notificationURL, coordinator);
            }
            synchronized (notificationLock) {
                notificationLock.notify();
            }

        } catch (IllegalStateException e) {
            logger.warn("Cannot play sound ({})", e.getMessage());
        }
    }
}

From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java

public void playRadio(Command command) {

    if (command instanceof StringType) {
        String station = command.toString();
        List<SonosEntry> stations = getFavoriteRadios();

        SonosEntry theEntry = null;//from  w  w  w.  j av  a 2 s . com
        // search for the appropriate radio based on its name (title)
        for (SonosEntry someStation : stations) {
            if (someStation.getTitle().equals(station)) {
                theEntry = someStation;
                break;
            }
        }

        // set the URI of the group coordinator
        if (theEntry != null) {
            try {
                ZonePlayerHandler coordinator = getCoordinatorHandler();
                coordinator.setCurrentURI(theEntry);
                coordinator.play();
            } catch (IllegalStateException e) {
                logger.warn("Cannot play radio ({})", e.getMessage());
            }
        } else {
            logger.warn("Radio station '{}' not found", station);
        }
    }

}

From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java

public void setRepeat(Command command) {
    if ((command != null) && (command instanceof StringType)) {
        try {//from   ww  w. j ava 2  s .com
            ZonePlayerHandler coordinator = getCoordinatorHandler();

            switch (command.toString()) {
            case "ALL":
                coordinator.updatePlayMode(coordinator.isShuffleActive() ? "SHUFFLE" : "REPEAT_ALL");
                break;
            case "ONE":
                coordinator.updatePlayMode(coordinator.isShuffleActive() ? "SHUFFLE_REPEAT_ONE" : "REPEAT_ONE");
                break;
            case "OFF":
                coordinator.updatePlayMode(coordinator.isShuffleActive() ? "SHUFFLE_NOREPEAT" : "NORMAL");
                break;
            default:
                logger.warn("{}: unexpected repeat command; accepted values are ALL, ONE and OFF",
                        command.toString());
                break;
            }

        } catch (IllegalStateException e) {
            logger.warn("Cannot handle repeat command ({})", e.getMessage());
        }
    }
}

From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java

/**
 * Play a given url to music in one of the music libraries.
 *
 * @param url//w w w .j a v a2  s. c o m
 *            in the format of //host/folder/filename.mp3
 */
public void playURI(Command command) {

    if (command != null && command instanceof StringType) {

        try {
            String url = command.toString();

            ZonePlayerHandler coordinator = getCoordinatorHandler();

            // stop whatever is currently playing
            coordinator.stop();
            coordinator.waitForNotTransportState("PLAYING");

            // clear any tracks which are pending in the queue
            coordinator.removeAllTracksFromQueue();

            // add the new track we want to play to the queue
            // The url will be prefixed with x-file-cifs if it is NOT a http URL
            if (!url.startsWith("x-") && (!url.startsWith("http"))) {
                // default to file based url
                url = FILE_URI + url;
            }
            coordinator.addURIToQueue(url, "", 0, true);

            // set the current playlist to our new queue
            coordinator.setCurrentURI(QUEUE_URI + coordinator.getUDN() + "#0", "");

            // take the system off mute
            coordinator.setMute(OnOffType.OFF);

            // start jammin'
            coordinator.play();

        } catch (IllegalStateException e) {
            logger.warn("Cannot play URI ({})", e.getMessage());
        }
    }

}

From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java

/**
 * Play music from the line-in of the given Player referenced by the given UDN or name
 *
 * @param udn or name//from  www.  j  av a  2s  .  co m
 */
public void playLineIn(Command command) {

    if (command != null && command instanceof StringType) {

        try {
            String remotePlayerName = command.toString();
            ZonePlayerHandler coordinatorHandler = getCoordinatorHandler();
            ZonePlayerHandler remoteHandler = getHandlerByName(remotePlayerName);

            // check if player has a line-in connected
            if (remoteHandler.isAnalogLineInConnected() || remoteHandler.isOpticalLineInConnected()) {

                // stop whatever is currently playing
                coordinatorHandler.stop();

                // set the URI
                if (remoteHandler.isAnalogLineInConnected()) {
                    coordinatorHandler.setCurrentURI(ANALOG_LINE_IN_URI + remoteHandler.getUDN(), "");
                } else {
                    coordinatorHandler.setCurrentURI(OPTICAL_LINE_IN_URI + remoteHandler.getUDN() + SPDIF, "");
                }

                // take the system off mute
                coordinatorHandler.setMute(OnOffType.OFF);

                // start jammin'
                coordinatorHandler.play();
            } else {
                logger.warn("Line-in of {} is not connected", remoteHandler.getUDN());
            }

        } catch (IllegalStateException e) {
            logger.warn("Cannot play line-in ({})", e.getMessage());
        }
    }
}

From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java

private void dispatchOnAllGroupMembers(String variable, String value, String service) {
    if (isCoordinator()) {
        for (String member : getOtherZoneGroupMembers()) {
            try {
                ZonePlayerHandler memberHandler = getHandlerByName(member);
                if (memberHandler != null && memberHandler.getThing() != null
                        && ThingStatus.ONLINE.equals(memberHandler.getThing().getStatus())) {
                    memberHandler.onValueReceived(variable, value, service);
                }//from  w  w w .  j av  a 2s  . co m
            } catch (IllegalStateException e) {
                logger.warn("Cannot update channel for group member ({})", e.getMessage());
            }
        }
    }
}

From source file:org.eclipse.smarthome.binding.sonos.handler.ZonePlayerHandler.java

public void playPlayList(Command command) {

    if (command != null && command instanceof StringType) {
        String playlist = command.toString();
        List<SonosEntry> playlists = getPlayLists();

        SonosEntry theEntry = null;//from   www .ja v  a  2  s. co m
        // search for the appropriate play list based on its name (title)
        for (SonosEntry somePlaylist : playlists) {
            if (somePlaylist.getTitle().equals(playlist)) {
                theEntry = somePlaylist;
                break;
            }
        }

        // set the URI of the group coordinator
        if (theEntry != null) {
            try {
                ZonePlayerHandler coordinator = getCoordinatorHandler();

                coordinator.addURIToQueue(theEntry);

                coordinator.setCurrentURI(QUEUE_URI + coordinator.getUDN() + "#0", "");

                String firstTrackNumberEnqueued = stateMap.get("FirstTrackNumberEnqueued");
                if (firstTrackNumberEnqueued != null) {
                    coordinator.seek("TRACK_NR", firstTrackNumberEnqueued);
                }

                coordinator.play();
            } catch (IllegalStateException e) {
                logger.warn("Cannot play playlist ({})", e.getMessage());
            }
        } else {
            logger.warn("Playlist '{}' not found", playlist);
        }
    }
}