	public void doWrite(Query query) throws Exception {
		Socket socket = null;
		statusLock.lock();
		try {
			while(status == GraphiteWriterStatus.STARTING) {
				statusConditionStarted.await();
			}
			if (status != GraphiteWriterStatus.STARTED) {
				throw new LifecycleException("GraphiteWriter instance should be started");
			}
			socket = (Socket) pool.borrowObject(address);
		} finally {
			statusLock.unlock();
		}
		try {
			PrintWriter writer = new PrintWriter(socket.getOutputStream(), true);
			List<String> typeNames = this.getTypeNames();
			for (Result result : query.getResults()) {
				if (isDebugEnabled()) {
					log.debug("Query result: " + result.toString());
				}
				Map<String, Object> resultValues = result.getValues();
				if (resultValues != null) {
					for (Entry<String, Object> values : resultValues.entrySet()) {
                        Object value = values.getValue();
                        if (JmxUtils.isNumeric(value)) {
							StringBuilder sb = new StringBuilder();
							sb.append(JmxUtils.getKeyString(query, result, values, typeNames, rootPrefix).replaceAll("[()]", "_"));
							sb.append(" ");
							sb.append(value.toString());
							sb.append(" ");
							sb.append(result.getEpoch() / 1000);
							sb.append("\n");
							String line = sb.toString();
							if (isDebugEnabled()) {
								log.debug("Graphite Message: " + line.trim());
							}
							writer.write(line);
							writer.flush();
						} else {
                            if (log.isWarnEnabled()) {
                                log.warn("Unable to submit non-numeric value to Graphite: \"" + value + "\" from result " + result);
                            }
                        }
					}
				}
			}
		} finally {
			pool.returnObject(address, socket);
		}
	}

	public void doWrite(Query query) throws Exception {
		Socket socket = null;
		statusLock.lock();
		try {
			while (status == GraphiteWriterStatus.STARTING) {
				statusConditionStarted.await();
			}
			if (status != GraphiteWriterStatus.STARTED) {
				throw new LifecycleException("GraphiteWriter instance should be started");
			}
			socket = (Socket) pool.borrowObject(address);
		} finally {
			statusLock.unlock();
		}
		try {
			PrintWriter writer = new PrintWriter(socket.getOutputStream(), true);
			List<String> typeNames = this.getTypeNames();
			for (Result result : query.getResults()) {
				if (isDebugEnabled()) {
					log.debug("Query result: " + result.toString());
				}
				Map<String, Object> resultValues = result.getValues();
				if (resultValues != null) {
					for (Entry<String, Object> values : resultValues.entrySet()) {
						Object value = values.getValue();
						if (JmxUtils.isNumeric(value)) {
							StringBuilder sb = new StringBuilder();
							sb.append(JmxUtils.getKeyString(query, result, values, typeNames, rootPrefix).replaceAll("[()]", "_"));
							sb.append(" ");
							sb.append(value.toString());
							sb.append(" ");
							sb.append(result.getEpoch() / 1000);
							sb.append("\n");
							String line = sb.toString();
							if (isDebugEnabled()) {
								log.debug("Graphite Message: " + line.trim());
							}
							writer.write(line);
							writer.flush();
						} else {
							if (log.isWarnEnabled()) {
								log.warn("Unable to submit non-numeric value to Graphite: \"" + value + "\" from result " + result);
							}
						}
					}
				}
			}
		} finally {
			pool.returnObject(address, socket);
		}
	}
