forked from box/opentsdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made HTTP Request method checking consistent, fixes a few cases where…
… behavior is unexpected. Simplified loading of internal RPC Handlers Stop Sending BAD_REQUEST response as a PNG, allowed random code execution! Fixes OpenTSDB#793 Fixes OpenTSDB#781 Fixes OpenTSDB#831 Fixes OpenTSDB#830
- Loading branch information
1 parent
1409b55
commit 85047ea
Showing
19 changed files
with
299 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// This file is part of OpenTSDB. | ||
// Copyright (C) 2013 The OpenTSDB Authors. | ||
// | ||
// This program is free software: you can redistribute it and/or modify it | ||
// under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 2.1 of the License, or (at your | ||
// option) any later version. This program is distributed in the hope that it | ||
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | ||
// General Public License for more details. You should have received a copy | ||
// of the GNU Lesser General Public License along with this program. If not, | ||
// see <http://www.gnu.org/licenses/>. | ||
package net.opentsdb.tsd; | ||
|
||
import java.io.IOException; | ||
import java.lang.reflect.Method; | ||
import java.net.URI; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
import java.util.regex.Pattern; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
import com.google.common.base.Preconditions; | ||
import com.google.common.base.Splitter; | ||
import com.google.common.base.Strings; | ||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.collect.Lists; | ||
import com.google.common.util.concurrent.Atomics; | ||
import com.stumbleupon.async.Callback; | ||
import com.stumbleupon.async.Deferred; | ||
|
||
import org.jboss.netty.channel.Channel; | ||
import org.jboss.netty.handler.codec.http.HttpMethod; | ||
import org.jboss.netty.handler.codec.http.HttpResponseStatus; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import net.opentsdb.tools.BuildData; | ||
import net.opentsdb.core.Aggregators; | ||
import net.opentsdb.core.TSDB; | ||
import net.opentsdb.query.filter.TagVFilter; | ||
import net.opentsdb.stats.StatsCollector; | ||
import net.opentsdb.utils.Config; | ||
import net.opentsdb.utils.JSON; | ||
import net.opentsdb.utils.PluginLoader; | ||
|
||
import java.io.IOException; | ||
|
||
/** The "dropcaches" command. */ | ||
public final class DropCachesRpc implements TelnetRpc, HttpRpc { | ||
private static final Logger LOG = LoggerFactory.getLogger(DropCachesRpc.class); | ||
|
||
public Deferred<Object> execute(final TSDB tsdb, final Channel chan, | ||
final String[] cmd) { | ||
dropCaches(tsdb, chan); | ||
chan.write("Caches dropped.\n"); | ||
return Deferred.fromResult(null); | ||
} | ||
|
||
public void execute(final TSDB tsdb, final HttpQuery query) | ||
throws IOException { | ||
|
||
// only accept GET/DELETE | ||
RpcUtil.allowedMethods(query.method(), HttpMethod.GET.getName(), HttpMethod.DELETE.getName()); | ||
|
||
dropCaches(tsdb, query.channel()); | ||
|
||
if (query.apiVersion() > 0) { | ||
final HashMap<String, String> response = new HashMap<String, String>(); | ||
response.put("status", "200"); | ||
response.put("message", "Caches dropped"); | ||
query.sendReply(query.serializer().formatDropCachesV1(response)); | ||
} else { // deprecated API | ||
query.sendReply("Caches dropped.\n"); | ||
} | ||
} | ||
|
||
/** Drops in memory caches. */ | ||
private void dropCaches(final TSDB tsdb, final Channel chan) { | ||
LOG.warn(chan + " Dropping all in-memory caches."); | ||
tsdb.dropCaches(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.