| 126 | } |
| 127 | |
| 128 | @Override |
| 129 | public Deferred<Object> execute(final TSDB tsdb, final Channel chan, |
| 130 | final String[] cmd) { |
| 131 | telnet_requests.incrementAndGet(); |
| 132 | final DataPointType type; |
| 133 | final String command = cmd[0].toLowerCase(); |
| 134 | |
| 135 | if (command.equals("put")) { |
| 136 | type = DataPointType.PUT; |
| 137 | raw_dps.incrementAndGet(); |
| 138 | } else if (command.equals("rollup")) { |
| 139 | type = DataPointType.ROLLUP; |
| 140 | rollup_dps.incrementAndGet(); |
| 141 | } else if (command.equals("histogram")) { |
| 142 | type = DataPointType.HISTOGRAM; |
| 143 | raw_histograms.incrementAndGet(); |
| 144 | } else { |
| 145 | throw new IllegalArgumentException("Unrecognized command: " + cmd[0]); |
| 146 | } |
| 147 | |
| 148 | String errmsg = null; |
| 149 | try { |
| 150 | |
| 151 | checkAuthorization(tsdb, chan, command); |
| 152 | |
| 153 | /** |
| 154 | * Error callback that handles passing a data point to the storage |
| 155 | * exception handler as well as responding to the client when HBase |
| 156 | * is unable to write the data. |
| 157 | */ |
| 158 | final class PutErrback implements Callback<Object, Exception> { |
| 159 | @Override |
| 160 | public Object call(final Exception arg) { |
| 161 | String errmsg = null; |
| 162 | if (arg instanceof PleaseThrottleException) { |
| 163 | if (send_telnet_errors) { |
| 164 | errmsg = type + ": Please throttle writes: " + arg.getMessage() + '\n'; |
| 165 | } |
| 166 | inflight_exceeded.incrementAndGet(); |
| 167 | } else { |
| 168 | if (send_telnet_errors) { |
| 169 | errmsg = type + ": HBase error: " + arg.getMessage()+ '\n'; |
| 170 | } |
| 171 | if (arg instanceof HBaseException) { |
| 172 | hbase_errors.incrementAndGet(); |
| 173 | } else if (arg instanceof IllegalArgumentException) { |
| 174 | illegal_arguments.incrementAndGet(); |
| 175 | } else { |
| 176 | unknown_errors.incrementAndGet(); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | // we handle the storage exceptions here so as to avoid creating yet |
| 181 | // another callback object on every data point. |
| 182 | handleStorageException(tsdb, getDataPointFromString(tsdb, cmd), arg); |
| 183 | |
| 184 | if (send_telnet_errors) { |
| 185 | if (chan.isConnected()) { |