rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
orderManager.handleCounterpartyMessage(message);
photonController.handleCounterpartyMessage(message);
public void testHandleCounterpartyMessage() throws FieldNotFound { Message message = getTestableExecutionReport(); orderManager.handleCounterpartyMessage(message); EventList<MessageHolder> historyList = messageHistory.getAllMessagesList(); assertEquals(1, historyList.size()); assertEquals(IncomingMessageHolder.class, historyList.get(0).getClass()); assertEquals(MsgType.EXECUTION_REPORT, ((IncomingMessageHolder)historyList.get(0)).getMessage().getHeader().getString(MsgType.FIELD)); }
orderManager.handleMessage(aMessage);
photonController.handleMessage(aMessage);
public void testHandleCounterpartyMessages() throws FieldNotFound { Message[] messages = new Message[2]; messages[0] = getTestableExecutionReport(); messages[1] = getTestableExecutionReport(); for (Message aMessage : messages) { orderManager.handleMessage(aMessage); } EventList<MessageHolder> historyList = messageHistory.getAllMessagesList(); assertEquals(2, historyList.size()); assertEquals(IncomingMessageHolder.class, historyList.get(0).getClass()); assertEquals(IncomingMessageHolder.class, historyList.get(1).getClass()); assertEquals(MsgType.EXECUTION_REPORT, ((IncomingMessageHolder)historyList.get(0)).getMessage().getHeader().getString(MsgType.FIELD)); assertEquals(MsgType.EXECUTION_REPORT, ((IncomingMessageHolder)historyList.get(1)).getMessage().getHeader().getString(MsgType.FIELD)); }
orderManager.handleInternalMessage(message);
photonController.handleInternalMessage(message);
public void testHandleInternalMessage() throws FieldNotFound, MarketceteraException { Message message = FIXMessageUtil.newLimitOrder(new InternalID("ASDF"), Side.BUY, BigDecimal.ONE, new MSymbol("QWER"), BigDecimal.TEN, TimeInForce.DAY, null); orderManager.handleInternalMessage(message); EventList<MessageHolder> historyList = messageHistory.getAllMessagesList(); assertEquals(1, historyList.size()); assertEquals(OutgoingMessageHolder.class, historyList.get(0).getClass()); assertEquals(MsgType.ORDER_SINGLE, ((OutgoingMessageHolder)historyList.get(0)).getMessage().getHeader().getString(MsgType.FIELD)); }
orderManager.handleMessage(message);
photonController.handleMessage(message);
public void testHandleInternalMessages() throws FieldNotFound { EventList<MessageHolder> historyList = messageHistory.getAllMessagesList(); assertEquals(0, historyList.size()); Message[] messages = new Message[2]; messages[0] = FIXMessageUtil.newLimitOrder(new InternalID("ASDF"), Side.BUY, BigDecimal.ONE, new MSymbol("QWER"), BigDecimal.TEN, TimeInForce.DAY, null); messages[1] = FIXMessageUtil.newCancel(new InternalID("AQWE"), new InternalID("ASDF"), Side.BUY, BigDecimal.TEN, new MSymbol("SDF"), "WERT"); for (Message message : messages) { orderManager.handleMessage(message); } assertNotNull(messageHistory.getLatestMessage("ASDF")); historyList = messageHistory.getAllMessagesList(); assertEquals(2, historyList.size()); assertEquals(OutgoingMessageHolder.class, historyList.get(0).getClass()); assertEquals(OutgoingMessageHolder.class, historyList.get(0).getClass()); assertEquals(MsgType.ORDER_SINGLE, ((OutgoingMessageHolder)historyList.get(0)).getMessage().getHeader().getString(MsgType.FIELD)); assertEquals(MsgType.ORDER_CANCEL_REQUEST, ((OutgoingMessageHolder)historyList.get(1)).getMessage().getHeader().getString(MsgType.FIELD)); }
throw new InitializationException("unable to connect incoming queue "+incomingQueueName);
throw new InitializationException(MessageKey.JMS_QUEUE_CONNECT_ERROR.getLocalizedMessage(incomingQueueName));
public void initialize(IStageManager stagemgr, ISystemManager sysmgr, String pluginName) throws Exception { super.initialize(stagemgr, sysmgr, pluginName); OrderManagementSystem oms = OrderManagementSystem.getOMS(); ConfigData props = oms.getInitProps(); String incomingQueueName = props.get(ConnectionConstants.JMS_INCOMING_QUEUE_KEY, ""); String outgoingTopicName = props.get(ConnectionConstants.JMS_OUTGOING_TOPIC_KEY, ""); String connectionFactory = props.get(ConnectionConstants.JMS_CONNECTION_FACTORY_KEY, ""); String initialContextFactory = props.get(ConnectionConstants.JMS_CONTEXT_FACTORY_KEY, ""); String url = props.get(ConnectionConstants.JMS_URL_KEY, ""); jmsAdapter = new JMSAdapter(initialContextFactory, url, connectionFactory, true); if(incomingQueueName != null) { jmsAdapter.connectIncomingQueue(INCOMING_QUEUE_NAME, incomingQueueName, Session.AUTO_ACKNOWLEDGE); } else { throw new InitializationException("unable to connect incoming queue "+incomingQueueName); } if(outgoingTopicName != null) { jmsAdapter.connectOutgoingTopic(OUTGOING_TOPIC_NAME, outgoingTopicName, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = jmsAdapter.getOutgoingTopicPublisher(OUTGOING_TOPIC_NAME); Session session = jmsAdapter.getOutgoingTopicSession(OUTGOING_TOPIC_NAME); oms.registerOutgoingJMSInfo(new JMSOutputInfo(producer, session, outgoingTopicName)); } else { throw new InitializationException("unable to connect topic "+outgoingTopicName); } setMessageListener(new MessageListener() { public void onMessage(Message message) { try { quickfix.Message qfMessage = null; if(message instanceof TextMessage) { if(LoggerAdapter.isDebugEnabled(this)) { LoggerAdapter.debug("Received JMS msg: "+message, this); } // todo: handle validation when creating quickfix message qfMessage = new quickfix.Message(((TextMessage)message).getText()); } else if (message instanceof BytesMessage){ LoggerAdapter.debug("Received JMS msg: "+message, this); try { BytesMessage bytesMessage = ((BytesMessage)message); int length = (int)bytesMessage.getBodyLength(); byte [] buf = new byte[length]; int numRead = bytesMessage.readBytes(buf); String possibleString = new String(buf, "UTF-16"); if (possibleString.startsWith("8=FIX")){ qfMessage = new quickfix.Message(possibleString); } } catch (Exception ex) { LoggerAdapter.error("Error decoding bytes", ex, this); } } if (qfMessage != null){ getNextStage().enqueue(new FIXStageOutput(qfMessage, OrderManagementSystem.getOMS().getDefaultSessionID())); } } catch (Exception ex) { LoggerAdapter.error("error sending QF message on a pipe", ex, this); // TODO: panic } } }); jmsAdapter.start(); }
throw new InitializationException("unable to connect topic "+outgoingTopicName);
throw new InitializationException(MessageKey.JMS_TOPIC_CONNECT_ERROR.getLocalizedMessage(outgoingTopicName));
public void initialize(IStageManager stagemgr, ISystemManager sysmgr, String pluginName) throws Exception { super.initialize(stagemgr, sysmgr, pluginName); OrderManagementSystem oms = OrderManagementSystem.getOMS(); ConfigData props = oms.getInitProps(); String incomingQueueName = props.get(ConnectionConstants.JMS_INCOMING_QUEUE_KEY, ""); String outgoingTopicName = props.get(ConnectionConstants.JMS_OUTGOING_TOPIC_KEY, ""); String connectionFactory = props.get(ConnectionConstants.JMS_CONNECTION_FACTORY_KEY, ""); String initialContextFactory = props.get(ConnectionConstants.JMS_CONTEXT_FACTORY_KEY, ""); String url = props.get(ConnectionConstants.JMS_URL_KEY, ""); jmsAdapter = new JMSAdapter(initialContextFactory, url, connectionFactory, true); if(incomingQueueName != null) { jmsAdapter.connectIncomingQueue(INCOMING_QUEUE_NAME, incomingQueueName, Session.AUTO_ACKNOWLEDGE); } else { throw new InitializationException("unable to connect incoming queue "+incomingQueueName); } if(outgoingTopicName != null) { jmsAdapter.connectOutgoingTopic(OUTGOING_TOPIC_NAME, outgoingTopicName, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = jmsAdapter.getOutgoingTopicPublisher(OUTGOING_TOPIC_NAME); Session session = jmsAdapter.getOutgoingTopicSession(OUTGOING_TOPIC_NAME); oms.registerOutgoingJMSInfo(new JMSOutputInfo(producer, session, outgoingTopicName)); } else { throw new InitializationException("unable to connect topic "+outgoingTopicName); } setMessageListener(new MessageListener() { public void onMessage(Message message) { try { quickfix.Message qfMessage = null; if(message instanceof TextMessage) { if(LoggerAdapter.isDebugEnabled(this)) { LoggerAdapter.debug("Received JMS msg: "+message, this); } // todo: handle validation when creating quickfix message qfMessage = new quickfix.Message(((TextMessage)message).getText()); } else if (message instanceof BytesMessage){ LoggerAdapter.debug("Received JMS msg: "+message, this); try { BytesMessage bytesMessage = ((BytesMessage)message); int length = (int)bytesMessage.getBodyLength(); byte [] buf = new byte[length]; int numRead = bytesMessage.readBytes(buf); String possibleString = new String(buf, "UTF-16"); if (possibleString.startsWith("8=FIX")){ qfMessage = new quickfix.Message(possibleString); } } catch (Exception ex) { LoggerAdapter.error("Error decoding bytes", ex, this); } } if (qfMessage != null){ getNextStage().enqueue(new FIXStageOutput(qfMessage, OrderManagementSystem.getOMS().getDefaultSessionID())); } } catch (Exception ex) { LoggerAdapter.error("error sending QF message on a pipe", ex, this); // TODO: panic } } }); jmsAdapter.start(); }
int numRead = bytesMessage.readBytes(buf);
public void initialize(IStageManager stagemgr, ISystemManager sysmgr, String pluginName) throws Exception { super.initialize(stagemgr, sysmgr, pluginName); OrderManagementSystem oms = OrderManagementSystem.getOMS(); ConfigData props = oms.getInitProps(); String incomingQueueName = props.get(ConnectionConstants.JMS_INCOMING_QUEUE_KEY, ""); String outgoingTopicName = props.get(ConnectionConstants.JMS_OUTGOING_TOPIC_KEY, ""); String connectionFactory = props.get(ConnectionConstants.JMS_CONNECTION_FACTORY_KEY, ""); String initialContextFactory = props.get(ConnectionConstants.JMS_CONTEXT_FACTORY_KEY, ""); String url = props.get(ConnectionConstants.JMS_URL_KEY, ""); jmsAdapter = new JMSAdapter(initialContextFactory, url, connectionFactory, true); if(incomingQueueName != null) { jmsAdapter.connectIncomingQueue(INCOMING_QUEUE_NAME, incomingQueueName, Session.AUTO_ACKNOWLEDGE); } else { throw new InitializationException("unable to connect incoming queue "+incomingQueueName); } if(outgoingTopicName != null) { jmsAdapter.connectOutgoingTopic(OUTGOING_TOPIC_NAME, outgoingTopicName, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = jmsAdapter.getOutgoingTopicPublisher(OUTGOING_TOPIC_NAME); Session session = jmsAdapter.getOutgoingTopicSession(OUTGOING_TOPIC_NAME); oms.registerOutgoingJMSInfo(new JMSOutputInfo(producer, session, outgoingTopicName)); } else { throw new InitializationException("unable to connect topic "+outgoingTopicName); } setMessageListener(new MessageListener() { public void onMessage(Message message) { try { quickfix.Message qfMessage = null; if(message instanceof TextMessage) { if(LoggerAdapter.isDebugEnabled(this)) { LoggerAdapter.debug("Received JMS msg: "+message, this); } // todo: handle validation when creating quickfix message qfMessage = new quickfix.Message(((TextMessage)message).getText()); } else if (message instanceof BytesMessage){ LoggerAdapter.debug("Received JMS msg: "+message, this); try { BytesMessage bytesMessage = ((BytesMessage)message); int length = (int)bytesMessage.getBodyLength(); byte [] buf = new byte[length]; int numRead = bytesMessage.readBytes(buf); String possibleString = new String(buf, "UTF-16"); if (possibleString.startsWith("8=FIX")){ qfMessage = new quickfix.Message(possibleString); } } catch (Exception ex) { LoggerAdapter.error("Error decoding bytes", ex, this); } } if (qfMessage != null){ getNextStage().enqueue(new FIXStageOutput(qfMessage, OrderManagementSystem.getOMS().getDefaultSessionID())); } } catch (Exception ex) { LoggerAdapter.error("error sending QF message on a pipe", ex, this); // TODO: panic } } }); jmsAdapter.start(); }
if (possibleString.startsWith("8=FIX")){
if (possibleString.startsWith(FIX_PREAMBLE)){
public void initialize(IStageManager stagemgr, ISystemManager sysmgr, String pluginName) throws Exception { super.initialize(stagemgr, sysmgr, pluginName); OrderManagementSystem oms = OrderManagementSystem.getOMS(); ConfigData props = oms.getInitProps(); String incomingQueueName = props.get(ConnectionConstants.JMS_INCOMING_QUEUE_KEY, ""); String outgoingTopicName = props.get(ConnectionConstants.JMS_OUTGOING_TOPIC_KEY, ""); String connectionFactory = props.get(ConnectionConstants.JMS_CONNECTION_FACTORY_KEY, ""); String initialContextFactory = props.get(ConnectionConstants.JMS_CONTEXT_FACTORY_KEY, ""); String url = props.get(ConnectionConstants.JMS_URL_KEY, ""); jmsAdapter = new JMSAdapter(initialContextFactory, url, connectionFactory, true); if(incomingQueueName != null) { jmsAdapter.connectIncomingQueue(INCOMING_QUEUE_NAME, incomingQueueName, Session.AUTO_ACKNOWLEDGE); } else { throw new InitializationException("unable to connect incoming queue "+incomingQueueName); } if(outgoingTopicName != null) { jmsAdapter.connectOutgoingTopic(OUTGOING_TOPIC_NAME, outgoingTopicName, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = jmsAdapter.getOutgoingTopicPublisher(OUTGOING_TOPIC_NAME); Session session = jmsAdapter.getOutgoingTopicSession(OUTGOING_TOPIC_NAME); oms.registerOutgoingJMSInfo(new JMSOutputInfo(producer, session, outgoingTopicName)); } else { throw new InitializationException("unable to connect topic "+outgoingTopicName); } setMessageListener(new MessageListener() { public void onMessage(Message message) { try { quickfix.Message qfMessage = null; if(message instanceof TextMessage) { if(LoggerAdapter.isDebugEnabled(this)) { LoggerAdapter.debug("Received JMS msg: "+message, this); } // todo: handle validation when creating quickfix message qfMessage = new quickfix.Message(((TextMessage)message).getText()); } else if (message instanceof BytesMessage){ LoggerAdapter.debug("Received JMS msg: "+message, this); try { BytesMessage bytesMessage = ((BytesMessage)message); int length = (int)bytesMessage.getBodyLength(); byte [] buf = new byte[length]; int numRead = bytesMessage.readBytes(buf); String possibleString = new String(buf, "UTF-16"); if (possibleString.startsWith("8=FIX")){ qfMessage = new quickfix.Message(possibleString); } } catch (Exception ex) { LoggerAdapter.error("Error decoding bytes", ex, this); } } if (qfMessage != null){ getNextStage().enqueue(new FIXStageOutput(qfMessage, OrderManagementSystem.getOMS().getDefaultSessionID())); } } catch (Exception ex) { LoggerAdapter.error("error sending QF message on a pipe", ex, this); // TODO: panic } } }); jmsAdapter.start(); }
LoggerAdapter.error("Error decoding bytes", ex, this);
LoggerAdapter.error(OMSMessageKey.ERROR_DECODING_MESSAGE.getLocalizedMessage(), ex, this);
public void initialize(IStageManager stagemgr, ISystemManager sysmgr, String pluginName) throws Exception { super.initialize(stagemgr, sysmgr, pluginName); OrderManagementSystem oms = OrderManagementSystem.getOMS(); ConfigData props = oms.getInitProps(); String incomingQueueName = props.get(ConnectionConstants.JMS_INCOMING_QUEUE_KEY, ""); String outgoingTopicName = props.get(ConnectionConstants.JMS_OUTGOING_TOPIC_KEY, ""); String connectionFactory = props.get(ConnectionConstants.JMS_CONNECTION_FACTORY_KEY, ""); String initialContextFactory = props.get(ConnectionConstants.JMS_CONTEXT_FACTORY_KEY, ""); String url = props.get(ConnectionConstants.JMS_URL_KEY, ""); jmsAdapter = new JMSAdapter(initialContextFactory, url, connectionFactory, true); if(incomingQueueName != null) { jmsAdapter.connectIncomingQueue(INCOMING_QUEUE_NAME, incomingQueueName, Session.AUTO_ACKNOWLEDGE); } else { throw new InitializationException("unable to connect incoming queue "+incomingQueueName); } if(outgoingTopicName != null) { jmsAdapter.connectOutgoingTopic(OUTGOING_TOPIC_NAME, outgoingTopicName, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = jmsAdapter.getOutgoingTopicPublisher(OUTGOING_TOPIC_NAME); Session session = jmsAdapter.getOutgoingTopicSession(OUTGOING_TOPIC_NAME); oms.registerOutgoingJMSInfo(new JMSOutputInfo(producer, session, outgoingTopicName)); } else { throw new InitializationException("unable to connect topic "+outgoingTopicName); } setMessageListener(new MessageListener() { public void onMessage(Message message) { try { quickfix.Message qfMessage = null; if(message instanceof TextMessage) { if(LoggerAdapter.isDebugEnabled(this)) { LoggerAdapter.debug("Received JMS msg: "+message, this); } // todo: handle validation when creating quickfix message qfMessage = new quickfix.Message(((TextMessage)message).getText()); } else if (message instanceof BytesMessage){ LoggerAdapter.debug("Received JMS msg: "+message, this); try { BytesMessage bytesMessage = ((BytesMessage)message); int length = (int)bytesMessage.getBodyLength(); byte [] buf = new byte[length]; int numRead = bytesMessage.readBytes(buf); String possibleString = new String(buf, "UTF-16"); if (possibleString.startsWith("8=FIX")){ qfMessage = new quickfix.Message(possibleString); } } catch (Exception ex) { LoggerAdapter.error("Error decoding bytes", ex, this); } } if (qfMessage != null){ getNextStage().enqueue(new FIXStageOutput(qfMessage, OrderManagementSystem.getOMS().getDefaultSessionID())); } } catch (Exception ex) { LoggerAdapter.error("error sending QF message on a pipe", ex, this); // TODO: panic } } }); jmsAdapter.start(); }
LoggerAdapter.error("error sending QF message on a pipe", ex, this);
LoggerAdapter.error(OMSMessageKey.ERROR_SENDING_QF_MESSAGE.getLocalizedMessage(), ex, this);
public void initialize(IStageManager stagemgr, ISystemManager sysmgr, String pluginName) throws Exception { super.initialize(stagemgr, sysmgr, pluginName); OrderManagementSystem oms = OrderManagementSystem.getOMS(); ConfigData props = oms.getInitProps(); String incomingQueueName = props.get(ConnectionConstants.JMS_INCOMING_QUEUE_KEY, ""); String outgoingTopicName = props.get(ConnectionConstants.JMS_OUTGOING_TOPIC_KEY, ""); String connectionFactory = props.get(ConnectionConstants.JMS_CONNECTION_FACTORY_KEY, ""); String initialContextFactory = props.get(ConnectionConstants.JMS_CONTEXT_FACTORY_KEY, ""); String url = props.get(ConnectionConstants.JMS_URL_KEY, ""); jmsAdapter = new JMSAdapter(initialContextFactory, url, connectionFactory, true); if(incomingQueueName != null) { jmsAdapter.connectIncomingQueue(INCOMING_QUEUE_NAME, incomingQueueName, Session.AUTO_ACKNOWLEDGE); } else { throw new InitializationException("unable to connect incoming queue "+incomingQueueName); } if(outgoingTopicName != null) { jmsAdapter.connectOutgoingTopic(OUTGOING_TOPIC_NAME, outgoingTopicName, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = jmsAdapter.getOutgoingTopicPublisher(OUTGOING_TOPIC_NAME); Session session = jmsAdapter.getOutgoingTopicSession(OUTGOING_TOPIC_NAME); oms.registerOutgoingJMSInfo(new JMSOutputInfo(producer, session, outgoingTopicName)); } else { throw new InitializationException("unable to connect topic "+outgoingTopicName); } setMessageListener(new MessageListener() { public void onMessage(Message message) { try { quickfix.Message qfMessage = null; if(message instanceof TextMessage) { if(LoggerAdapter.isDebugEnabled(this)) { LoggerAdapter.debug("Received JMS msg: "+message, this); } // todo: handle validation when creating quickfix message qfMessage = new quickfix.Message(((TextMessage)message).getText()); } else if (message instanceof BytesMessage){ LoggerAdapter.debug("Received JMS msg: "+message, this); try { BytesMessage bytesMessage = ((BytesMessage)message); int length = (int)bytesMessage.getBodyLength(); byte [] buf = new byte[length]; int numRead = bytesMessage.readBytes(buf); String possibleString = new String(buf, "UTF-16"); if (possibleString.startsWith("8=FIX")){ qfMessage = new quickfix.Message(possibleString); } } catch (Exception ex) { LoggerAdapter.error("Error decoding bytes", ex, this); } } if (qfMessage != null){ getNextStage().enqueue(new FIXStageOutput(qfMessage, OrderManagementSystem.getOMS().getDefaultSessionID())); } } catch (Exception ex) { LoggerAdapter.error("error sending QF message on a pipe", ex, this); // TODO: panic } } }); jmsAdapter.start(); }
int numRead = bytesMessage.readBytes(buf);
public void onMessage(Message message) { try { quickfix.Message qfMessage = null; if(message instanceof TextMessage) { if(LoggerAdapter.isDebugEnabled(this)) { LoggerAdapter.debug("Received JMS msg: "+message, this); } // todo: handle validation when creating quickfix message qfMessage = new quickfix.Message(((TextMessage)message).getText()); } else if (message instanceof BytesMessage){ LoggerAdapter.debug("Received JMS msg: "+message, this); try { BytesMessage bytesMessage = ((BytesMessage)message); int length = (int)bytesMessage.getBodyLength(); byte [] buf = new byte[length]; int numRead = bytesMessage.readBytes(buf); String possibleString = new String(buf, "UTF-16"); if (possibleString.startsWith("8=FIX")){ qfMessage = new quickfix.Message(possibleString); } } catch (Exception ex) { LoggerAdapter.error("Error decoding bytes", ex, this); } } if (qfMessage != null){ getNextStage().enqueue(new FIXStageOutput(qfMessage, OrderManagementSystem.getOMS().getDefaultSessionID())); } } catch (Exception ex) { LoggerAdapter.error("error sending QF message on a pipe", ex, this); // TODO: panic } }
if (possibleString.startsWith("8=FIX")){
if (possibleString.startsWith(FIX_PREAMBLE)){
public void onMessage(Message message) { try { quickfix.Message qfMessage = null; if(message instanceof TextMessage) { if(LoggerAdapter.isDebugEnabled(this)) { LoggerAdapter.debug("Received JMS msg: "+message, this); } // todo: handle validation when creating quickfix message qfMessage = new quickfix.Message(((TextMessage)message).getText()); } else if (message instanceof BytesMessage){ LoggerAdapter.debug("Received JMS msg: "+message, this); try { BytesMessage bytesMessage = ((BytesMessage)message); int length = (int)bytesMessage.getBodyLength(); byte [] buf = new byte[length]; int numRead = bytesMessage.readBytes(buf); String possibleString = new String(buf, "UTF-16"); if (possibleString.startsWith("8=FIX")){ qfMessage = new quickfix.Message(possibleString); } } catch (Exception ex) { LoggerAdapter.error("Error decoding bytes", ex, this); } } if (qfMessage != null){ getNextStage().enqueue(new FIXStageOutput(qfMessage, OrderManagementSystem.getOMS().getDefaultSessionID())); } } catch (Exception ex) { LoggerAdapter.error("error sending QF message on a pipe", ex, this); // TODO: panic } }
LoggerAdapter.error("Error decoding bytes", ex, this);
LoggerAdapter.error(OMSMessageKey.ERROR_DECODING_MESSAGE.getLocalizedMessage(), ex, this);
public void onMessage(Message message) { try { quickfix.Message qfMessage = null; if(message instanceof TextMessage) { if(LoggerAdapter.isDebugEnabled(this)) { LoggerAdapter.debug("Received JMS msg: "+message, this); } // todo: handle validation when creating quickfix message qfMessage = new quickfix.Message(((TextMessage)message).getText()); } else if (message instanceof BytesMessage){ LoggerAdapter.debug("Received JMS msg: "+message, this); try { BytesMessage bytesMessage = ((BytesMessage)message); int length = (int)bytesMessage.getBodyLength(); byte [] buf = new byte[length]; int numRead = bytesMessage.readBytes(buf); String possibleString = new String(buf, "UTF-16"); if (possibleString.startsWith("8=FIX")){ qfMessage = new quickfix.Message(possibleString); } } catch (Exception ex) { LoggerAdapter.error("Error decoding bytes", ex, this); } } if (qfMessage != null){ getNextStage().enqueue(new FIXStageOutput(qfMessage, OrderManagementSystem.getOMS().getDefaultSessionID())); } } catch (Exception ex) { LoggerAdapter.error("error sending QF message on a pipe", ex, this); // TODO: panic } }
LoggerAdapter.error("error sending QF message on a pipe", ex, this);
LoggerAdapter.error(OMSMessageKey.ERROR_SENDING_QF_MESSAGE.getLocalizedMessage(), ex, this);
public void onMessage(Message message) { try { quickfix.Message qfMessage = null; if(message instanceof TextMessage) { if(LoggerAdapter.isDebugEnabled(this)) { LoggerAdapter.debug("Received JMS msg: "+message, this); } // todo: handle validation when creating quickfix message qfMessage = new quickfix.Message(((TextMessage)message).getText()); } else if (message instanceof BytesMessage){ LoggerAdapter.debug("Received JMS msg: "+message, this); try { BytesMessage bytesMessage = ((BytesMessage)message); int length = (int)bytesMessage.getBodyLength(); byte [] buf = new byte[length]; int numRead = bytesMessage.readBytes(buf); String possibleString = new String(buf, "UTF-16"); if (possibleString.startsWith("8=FIX")){ qfMessage = new quickfix.Message(possibleString); } } catch (Exception ex) { LoggerAdapter.error("Error decoding bytes", ex, this); } } if (qfMessage != null){ getNextStage().enqueue(new FIXStageOutput(qfMessage, OrderManagementSystem.getOMS().getDefaultSessionID())); } } catch (Exception ex) { LoggerAdapter.error("error sending QF message on a pipe", ex, this); // TODO: panic } }
new IConsole[] { new MainConsole() });
new IConsole[] { mainConsole }); System.setOut(new PrintStream(mainConsole.getInfoMessageStream(), true)); System.setErr(new PrintStream(mainConsole.getErrorMessageStream(), true));
public void initialize(IWorkbenchConfigurer configurer) { configurer.setSaveAndRestore(true); registerIdeAdapters(); declareIdeWorkbenchImages(); ConsolePlugin.getDefault().getConsoleManager().addConsoles( new IConsole[] { new MainConsole() }); }
LoggerAdapter.info("Starting.", LOGGER_NAME);
LoggerAdapter.info(MessageKey.APP_START.getLocalizedMessage("OMS"), LOGGER_NAME);
public static void main(String [] args) throws ConfigFileLoadingException { String configFile = CONFIG_FILE_NAME; if(args.length == 1) { configFile = args[0]; } sOMS = createOMS(configFile); try { sOMS.init(); LoggerAdapter.info("Starting.", LOGGER_NAME); sOMS.run(); Thread.currentThread().join(); } catch (JMSException jmse) { LoggerAdapter.error("JMS error", jmse, LOGGER_NAME); } catch (quickfix.ConfigError ce) { LoggerAdapter.error("Config error", ce, LOGGER_NAME); } catch (FileNotFoundException fnf) { LoggerAdapter.error("Config file not found: ", fnf, LOGGER_NAME); } catch (ClassNotFoundException cnfe) { LoggerAdapter.error("Class not found ", cnfe, LOGGER_NAME); } catch (Exception ex) { LoggerAdapter.error("Error", ex, LOGGER_NAME); } finally { LoggerAdapter.info("Exiting application.", LOGGER_NAME); } }
LoggerAdapter.error("JMS error", jmse, LOGGER_NAME);
LoggerAdapter.error(MessageKey.JMS_ERROR.getLocalizedMessage(), jmse, LOGGER_NAME);
public static void main(String [] args) throws ConfigFileLoadingException { String configFile = CONFIG_FILE_NAME; if(args.length == 1) { configFile = args[0]; } sOMS = createOMS(configFile); try { sOMS.init(); LoggerAdapter.info("Starting.", LOGGER_NAME); sOMS.run(); Thread.currentThread().join(); } catch (JMSException jmse) { LoggerAdapter.error("JMS error", jmse, LOGGER_NAME); } catch (quickfix.ConfigError ce) { LoggerAdapter.error("Config error", ce, LOGGER_NAME); } catch (FileNotFoundException fnf) { LoggerAdapter.error("Config file not found: ", fnf, LOGGER_NAME); } catch (ClassNotFoundException cnfe) { LoggerAdapter.error("Class not found ", cnfe, LOGGER_NAME); } catch (Exception ex) { LoggerAdapter.error("Error", ex, LOGGER_NAME); } finally { LoggerAdapter.info("Exiting application.", LOGGER_NAME); } }
LoggerAdapter.error("Config error", ce, LOGGER_NAME);
LoggerAdapter.error(MessageKey.CONFIG_ERROR.getLocalizedMessage(), ce, LOGGER_NAME);
public static void main(String [] args) throws ConfigFileLoadingException { String configFile = CONFIG_FILE_NAME; if(args.length == 1) { configFile = args[0]; } sOMS = createOMS(configFile); try { sOMS.init(); LoggerAdapter.info("Starting.", LOGGER_NAME); sOMS.run(); Thread.currentThread().join(); } catch (JMSException jmse) { LoggerAdapter.error("JMS error", jmse, LOGGER_NAME); } catch (quickfix.ConfigError ce) { LoggerAdapter.error("Config error", ce, LOGGER_NAME); } catch (FileNotFoundException fnf) { LoggerAdapter.error("Config file not found: ", fnf, LOGGER_NAME); } catch (ClassNotFoundException cnfe) { LoggerAdapter.error("Class not found ", cnfe, LOGGER_NAME); } catch (Exception ex) { LoggerAdapter.error("Error", ex, LOGGER_NAME); } finally { LoggerAdapter.info("Exiting application.", LOGGER_NAME); } }
LoggerAdapter.error("Config file not found: ", fnf, LOGGER_NAME);
LoggerAdapter.error(MessageKey.CONFIG_FILE_DNE.getLocalizedMessage(), fnf, LOGGER_NAME);
public static void main(String [] args) throws ConfigFileLoadingException { String configFile = CONFIG_FILE_NAME; if(args.length == 1) { configFile = args[0]; } sOMS = createOMS(configFile); try { sOMS.init(); LoggerAdapter.info("Starting.", LOGGER_NAME); sOMS.run(); Thread.currentThread().join(); } catch (JMSException jmse) { LoggerAdapter.error("JMS error", jmse, LOGGER_NAME); } catch (quickfix.ConfigError ce) { LoggerAdapter.error("Config error", ce, LOGGER_NAME); } catch (FileNotFoundException fnf) { LoggerAdapter.error("Config file not found: ", fnf, LOGGER_NAME); } catch (ClassNotFoundException cnfe) { LoggerAdapter.error("Class not found ", cnfe, LOGGER_NAME); } catch (Exception ex) { LoggerAdapter.error("Error", ex, LOGGER_NAME); } finally { LoggerAdapter.info("Exiting application.", LOGGER_NAME); } }
LoggerAdapter.error("Class not found ", cnfe, LOGGER_NAME);
LoggerAdapter.error(MessageKey.CLASS_DNE.getLocalizedMessage(), cnfe, LOGGER_NAME);
public static void main(String [] args) throws ConfigFileLoadingException { String configFile = CONFIG_FILE_NAME; if(args.length == 1) { configFile = args[0]; } sOMS = createOMS(configFile); try { sOMS.init(); LoggerAdapter.info("Starting.", LOGGER_NAME); sOMS.run(); Thread.currentThread().join(); } catch (JMSException jmse) { LoggerAdapter.error("JMS error", jmse, LOGGER_NAME); } catch (quickfix.ConfigError ce) { LoggerAdapter.error("Config error", ce, LOGGER_NAME); } catch (FileNotFoundException fnf) { LoggerAdapter.error("Config file not found: ", fnf, LOGGER_NAME); } catch (ClassNotFoundException cnfe) { LoggerAdapter.error("Class not found ", cnfe, LOGGER_NAME); } catch (Exception ex) { LoggerAdapter.error("Error", ex, LOGGER_NAME); } finally { LoggerAdapter.info("Exiting application.", LOGGER_NAME); } }
LoggerAdapter.error("Error", ex, LOGGER_NAME);
LoggerAdapter.error(MessageKey.ERROR.getLocalizedMessage(), ex, LOGGER_NAME);
public static void main(String [] args) throws ConfigFileLoadingException { String configFile = CONFIG_FILE_NAME; if(args.length == 1) { configFile = args[0]; } sOMS = createOMS(configFile); try { sOMS.init(); LoggerAdapter.info("Starting.", LOGGER_NAME); sOMS.run(); Thread.currentThread().join(); } catch (JMSException jmse) { LoggerAdapter.error("JMS error", jmse, LOGGER_NAME); } catch (quickfix.ConfigError ce) { LoggerAdapter.error("Config error", ce, LOGGER_NAME); } catch (FileNotFoundException fnf) { LoggerAdapter.error("Config file not found: ", fnf, LOGGER_NAME); } catch (ClassNotFoundException cnfe) { LoggerAdapter.error("Class not found ", cnfe, LOGGER_NAME); } catch (Exception ex) { LoggerAdapter.error("Error", ex, LOGGER_NAME); } finally { LoggerAdapter.info("Exiting application.", LOGGER_NAME); } }
LoggerAdapter.info("Exiting application.", LOGGER_NAME);
LoggerAdapter.info(MessageKey.APP_EXIT.getLocalizedMessage(), LOGGER_NAME);
public static void main(String [] args) throws ConfigFileLoadingException { String configFile = CONFIG_FILE_NAME; if(args.length == 1) { configFile = args[0]; } sOMS = createOMS(configFile); try { sOMS.init(); LoggerAdapter.info("Starting.", LOGGER_NAME); sOMS.run(); Thread.currentThread().join(); } catch (JMSException jmse) { LoggerAdapter.error("JMS error", jmse, LOGGER_NAME); } catch (quickfix.ConfigError ce) { LoggerAdapter.error("Config error", ce, LOGGER_NAME); } catch (FileNotFoundException fnf) { LoggerAdapter.error("Config file not found: ", fnf, LOGGER_NAME); } catch (ClassNotFoundException cnfe) { LoggerAdapter.error("Class not found ", cnfe, LOGGER_NAME); } catch (Exception ex) { LoggerAdapter.error("Error", ex, LOGGER_NAME); } finally { LoggerAdapter.info("Exiting application.", LOGGER_NAME); } }
public boolean fireInEventDispathThread() { return false; }
private void init() { checkList = new LinkedList<Member>(); nodeListener = new NodeManagerListener() { public void nodeRemoved(NodeManagerEvent e) { } public void nodeAdded(NodeManagerEvent e) { synchronized (FriendSearcher.this) { checkList.add(e.getNode()); FriendSearcher.this.notifyAll(); } } public void nodeConnected(NodeManagerEvent e) { } public void nodeDisconnected(NodeManagerEvent e) { } public void friendAdded(NodeManagerEvent e) { } public void friendRemoved(NodeManagerEvent e) { } public void settingsChanged(NodeManagerEvent e) { } }; getController().getNodeManager().addNodeManagerListener(nodeListener); }
FileInfoComparator comp = directoryTable .getDirectoryTableModel().getComparator();
int compType = directoryTable .getDirectoryTableModel().getComparatorType();
private void update0() { Runnable runner = new Runnable() { public void run() { isUpdating = true; Directory dir = directoryTable.getDirectory(); SelectionModel oldSelections = selectionModel; Object[] selections = oldSelections.getSelections(); FileInfoComparator comp = directoryTable .getDirectoryTableModel().getComparator(); directoryTable .setModel(new DirectoryTableModel(fileFilterModel)); directoryTable.getDirectoryTableModel() .setTable(directoryTable); directoryTable.setColumnSizes(); boolean recursive = recursiveSelection.isSelected(); directoryTable.getDirectoryTableModel().setRecursive(recursive, false); directoryTable.getDirectoryTableModel().sortBy(comp, false); // not_now directoryTable.setDirectory(dir, false, selections); lastUpdate = System.currentTimeMillis(); isUpdating = false; } }; UIUtil.invokeLaterInEDT(runner); }
directoryTable.getDirectoryTableModel().sortBy(comp, false);
directoryTable.getDirectoryTableModel().sortBy(compType, false);
private void update0() { Runnable runner = new Runnable() { public void run() { isUpdating = true; Directory dir = directoryTable.getDirectory(); SelectionModel oldSelections = selectionModel; Object[] selections = oldSelections.getSelections(); FileInfoComparator comp = directoryTable .getDirectoryTableModel().getComparator(); directoryTable .setModel(new DirectoryTableModel(fileFilterModel)); directoryTable.getDirectoryTableModel() .setTable(directoryTable); directoryTable.setColumnSizes(); boolean recursive = recursiveSelection.isSelected(); directoryTable.getDirectoryTableModel().setRecursive(recursive, false); directoryTable.getDirectoryTableModel().sortBy(comp, false); // not_now directoryTable.setDirectory(dir, false, selections); lastUpdate = System.currentTimeMillis(); isUpdating = false; } }; UIUtil.invokeLaterInEDT(runner); }
FileInfoComparator comp = directoryTable .getDirectoryTableModel().getComparator();
int compType = directoryTable .getDirectoryTableModel().getComparatorType();
public void run() { isUpdating = true; Directory dir = directoryTable.getDirectory(); SelectionModel oldSelections = selectionModel; Object[] selections = oldSelections.getSelections(); FileInfoComparator comp = directoryTable .getDirectoryTableModel().getComparator(); directoryTable .setModel(new DirectoryTableModel(fileFilterModel)); directoryTable.getDirectoryTableModel() .setTable(directoryTable); directoryTable.setColumnSizes(); boolean recursive = recursiveSelection.isSelected(); directoryTable.getDirectoryTableModel().setRecursive(recursive, false); directoryTable.getDirectoryTableModel().sortBy(comp, false); // not_now directoryTable.setDirectory(dir, false, selections); lastUpdate = System.currentTimeMillis(); isUpdating = false; }
directoryTable.getDirectoryTableModel().sortBy(comp, false);
directoryTable.getDirectoryTableModel().sortBy(compType, false);
public void run() { isUpdating = true; Directory dir = directoryTable.getDirectory(); SelectionModel oldSelections = selectionModel; Object[] selections = oldSelections.getSelections(); FileInfoComparator comp = directoryTable .getDirectoryTableModel().getComparator(); directoryTable .setModel(new DirectoryTableModel(fileFilterModel)); directoryTable.getDirectoryTableModel() .setTable(directoryTable); directoryTable.setColumnSizes(); boolean recursive = recursiveSelection.isSelected(); directoryTable.getDirectoryTableModel().setRecursive(recursive, false); directoryTable.getDirectoryTableModel().sortBy(comp, false); // not_now directoryTable.setDirectory(dir, false, selections); lastUpdate = System.currentTimeMillis(); isUpdating = false; }
log() .debug("start requesting");
public void run() { long waitTime = getController().getWaitTime() * 4; while (!myThread.isInterrupted()) { log() .debug("start requesting"); FolderInfo[] folders = getController().getFolderRepository() .getJoinedFolderInfos(); for (FolderInfo folderInfo : folders) { Folder folder = getController().getFolderRepository() .getFolder(folderInfo); // Download new files on folder if autodownload is wanted if (folder != null) { // maybe null during shutdown requestMissingFilesForAutodownload(folder); } } try { if (!triggered) { synchronized (requestTrigger) { // use waiter, will quit faster requestTrigger.wait(waitTime); } } triggered = false; // Sleep a bit to avoid spamming Thread.sleep(200); } catch (InterruptedException e) { log().verbose(e); break; } } }
if (folder == null) { log().error("PeriodicalRequestor.run folder == null!"); }
public void run() { long waitTime = getController().getWaitTime() * 4; while (!myThread.isInterrupted()) { log() .debug("start requesting"); FolderInfo[] folders = getController().getFolderRepository() .getJoinedFolderInfos(); for (FolderInfo folderInfo : folders) { Folder folder = getController().getFolderRepository() .getFolder(folderInfo); // Download new files on folder if autodownload is wanted if (folder != null) { // maybe null during shutdown requestMissingFilesForAutodownload(folder); } } try { if (!triggered) { synchronized (requestTrigger) { // use waiter, will quit faster requestTrigger.wait(waitTime); } } triggered = false; // Sleep a bit to avoid spamming Thread.sleep(200); } catch (InterruptedException e) { log().verbose(e); break; } } }
log().debug("not requesting because no own database");
public void requestMissingFilesForAutodownload(Folder folder) { if (!folder.getSyncProfile().isAutodownload()) { return; } if (logVerbose) { log().verbose("Requesting files (autodownload), has own DB? " + folder.hasOwnDatabase()); } // Dont request files until has own database if (!folder.hasOwnDatabase()) { return; } List<FileInfo> expectedFiles = folder.getIncomingFiles(folder .getSyncProfile().isAutoDownloadFromOthers()); TransferManager tm = getController().getTransferManager(); for (FileInfo fInfo : expectedFiles) { if (fInfo.isDeleted() || tm.isDownloadingActive(fInfo) || tm.isDownloadingPending(fInfo)) { // Already downloading/file is deleted continue; } boolean download = folder.getSyncProfile() .isAutoDownloadFromOthers() || (folder.getSyncProfile().isAutoDownloadFromFriends() && fInfo .getModifiedBy().getNode(getController()).isFriend()); if (download) { tm.downloadNewestVersion(fInfo, true); } } }
lowerCaseNames.get(fileInfo));
lowerCaseNames.get(fileInfo.getLowerCaseName()));
public static Map<FileInfo, List<FilenameProblem>> tryFindProblems( List<FileInfo> files) { Map<String, FileInfo> lowerCaseNames = new HashMap<String, FileInfo>(); Map<FileInfo, List<FilenameProblem>> returnValue = new HashMap<FileInfo, List<FilenameProblem>>(); for (FileInfo fileInfo : files) { List<FilenameProblem> problemList = null; if (lowerCaseNames.containsKey(fileInfo.getLowerCaseName())) { // possible dupe because of same filename but with different // case FilenameProblem problem = new FilenameProblem(fileInfo, lowerCaseNames.get(fileInfo)); problemList = new ArrayList<FilenameProblem>(1); problemList.add(problem); } if (FilenameProblem.hasProblems(fileInfo.getFilenameOnly())) { if (problemList == null) { problemList = new ArrayList<FilenameProblem>(1); } problemList.addAll(FilenameProblem.getProblems(fileInfo)); } if (problemList != null) { returnValue.put(fileInfo, problemList); } } return returnValue; }
} else { lowerCaseNames.put(fileInfo.getLowerCaseName(), fileInfo);
public static Map<FileInfo, List<FilenameProblem>> tryFindProblems( List<FileInfo> files) { Map<String, FileInfo> lowerCaseNames = new HashMap<String, FileInfo>(); Map<FileInfo, List<FilenameProblem>> returnValue = new HashMap<FileInfo, List<FilenameProblem>>(); for (FileInfo fileInfo : files) { List<FilenameProblem> problemList = null; if (lowerCaseNames.containsKey(fileInfo.getLowerCaseName())) { // possible dupe because of same filename but with different // case FilenameProblem problem = new FilenameProblem(fileInfo, lowerCaseNames.get(fileInfo)); problemList = new ArrayList<FilenameProblem>(1); problemList.add(problem); } if (FilenameProblem.hasProblems(fileInfo.getFilenameOnly())) { if (problemList == null) { problemList = new ArrayList<FilenameProblem>(1); } problemList.addAll(FilenameProblem.getProblems(fileInfo)); } if (problemList != null) { returnValue.put(fileInfo, problemList); } } return returnValue; }
String dyndnsHost = (String) mydnsndsModel.getValue(); if (!StringUtils.isBlank(dyndnsHost)) {
String theDyndnsHost = (String) mydnsndsModel.getValue(); if (!StringUtils.isBlank(theDyndnsHost)) {
public void save() { String dyndnsHost = (String) mydnsndsModel.getValue(); if (!StringUtils.isBlank(dyndnsHost)) { ConfigurationEntry.DYNDNS_HOSTNAME.setValue(getController(), dyndnsHost); } else { ConfigurationEntry.DYNDNS_HOSTNAME.removeValue(getController()); } if (!StringUtils.isBlank(dyndnsHost)) { if (!StringUtils.isBlank(dyndnsUserField.getText())) { ConfigurationEntry.DYNDNS_USERNAME.setValue(getController(), dyndnsUserField.getText()); } else { ConfigurationEntry.DYNDNS_USERNAME.removeValue(getController()); } String password = new String(dyndnsPasswordField.getPassword()); if (!StringUtils.isBlank(password)) { ConfigurationEntry.DYNDNS_PASSWORD.setValue(getController(), password); } else { ConfigurationEntry.DYNDNS_PASSWORD.removeValue(getController()); } } boolean b = onStartUpdateBox.isSelected(); ConfigurationEntry.DYNDNS_UPDATE_ON_START.setValue(getController(), Boolean.valueOf(b).toString()); }
dyndnsHost);
theDyndnsHost);
public void save() { String dyndnsHost = (String) mydnsndsModel.getValue(); if (!StringUtils.isBlank(dyndnsHost)) { ConfigurationEntry.DYNDNS_HOSTNAME.setValue(getController(), dyndnsHost); } else { ConfigurationEntry.DYNDNS_HOSTNAME.removeValue(getController()); } if (!StringUtils.isBlank(dyndnsHost)) { if (!StringUtils.isBlank(dyndnsUserField.getText())) { ConfigurationEntry.DYNDNS_USERNAME.setValue(getController(), dyndnsUserField.getText()); } else { ConfigurationEntry.DYNDNS_USERNAME.removeValue(getController()); } String password = new String(dyndnsPasswordField.getPassword()); if (!StringUtils.isBlank(password)) { ConfigurationEntry.DYNDNS_PASSWORD.setValue(getController(), password); } else { ConfigurationEntry.DYNDNS_PASSWORD.removeValue(getController()); } } boolean b = onStartUpdateBox.isSelected(); ConfigurationEntry.DYNDNS_UPDATE_ON_START.setValue(getController(), Boolean.valueOf(b).toString()); }
if (!StringUtils.isBlank(dyndnsHost)) {
if (!StringUtils.isBlank(theDyndnsHost)) {
public void save() { String dyndnsHost = (String) mydnsndsModel.getValue(); if (!StringUtils.isBlank(dyndnsHost)) { ConfigurationEntry.DYNDNS_HOSTNAME.setValue(getController(), dyndnsHost); } else { ConfigurationEntry.DYNDNS_HOSTNAME.removeValue(getController()); } if (!StringUtils.isBlank(dyndnsHost)) { if (!StringUtils.isBlank(dyndnsUserField.getText())) { ConfigurationEntry.DYNDNS_USERNAME.setValue(getController(), dyndnsUserField.getText()); } else { ConfigurationEntry.DYNDNS_USERNAME.removeValue(getController()); } String password = new String(dyndnsPasswordField.getPassword()); if (!StringUtils.isBlank(password)) { ConfigurationEntry.DYNDNS_PASSWORD.setValue(getController(), password); } else { ConfigurationEntry.DYNDNS_PASSWORD.removeValue(getController()); } } boolean b = onStartUpdateBox.isSelected(); ConfigurationEntry.DYNDNS_UPDATE_ON_START.setValue(getController(), Boolean.valueOf(b).toString()); }
String password = new String(dyndnsPasswordField.getPassword()); if (!StringUtils.isBlank(password)) {
String thePassword = new String(dyndnsPasswordField.getPassword()); if (!StringUtils.isBlank(thePassword)) {
public void save() { String dyndnsHost = (String) mydnsndsModel.getValue(); if (!StringUtils.isBlank(dyndnsHost)) { ConfigurationEntry.DYNDNS_HOSTNAME.setValue(getController(), dyndnsHost); } else { ConfigurationEntry.DYNDNS_HOSTNAME.removeValue(getController()); } if (!StringUtils.isBlank(dyndnsHost)) { if (!StringUtils.isBlank(dyndnsUserField.getText())) { ConfigurationEntry.DYNDNS_USERNAME.setValue(getController(), dyndnsUserField.getText()); } else { ConfigurationEntry.DYNDNS_USERNAME.removeValue(getController()); } String password = new String(dyndnsPasswordField.getPassword()); if (!StringUtils.isBlank(password)) { ConfigurationEntry.DYNDNS_PASSWORD.setValue(getController(), password); } else { ConfigurationEntry.DYNDNS_PASSWORD.removeValue(getController()); } } boolean b = onStartUpdateBox.isSelected(); ConfigurationEntry.DYNDNS_UPDATE_ON_START.setValue(getController(), Boolean.valueOf(b).toString()); }
password);
thePassword);
public void save() { String dyndnsHost = (String) mydnsndsModel.getValue(); if (!StringUtils.isBlank(dyndnsHost)) { ConfigurationEntry.DYNDNS_HOSTNAME.setValue(getController(), dyndnsHost); } else { ConfigurationEntry.DYNDNS_HOSTNAME.removeValue(getController()); } if (!StringUtils.isBlank(dyndnsHost)) { if (!StringUtils.isBlank(dyndnsUserField.getText())) { ConfigurationEntry.DYNDNS_USERNAME.setValue(getController(), dyndnsUserField.getText()); } else { ConfigurationEntry.DYNDNS_USERNAME.removeValue(getController()); } String password = new String(dyndnsPasswordField.getPassword()); if (!StringUtils.isBlank(password)) { ConfigurationEntry.DYNDNS_PASSWORD.setValue(getController(), password); } else { ConfigurationEntry.DYNDNS_PASSWORD.removeValue(getController()); } } boolean b = onStartUpdateBox.isSelected(); ConfigurationEntry.DYNDNS_UPDATE_ON_START.setValue(getController(), Boolean.valueOf(b).toString()); }
folderAtBart.scanLocalFiles(true);
folderAtBart.forceScanOnNextMaintenance(); folderAtBart.maintain();
public void testOverwriteToRecycleAndRestore() { FolderInfo testFolder = new FolderInfo("testFolder", IdGenerator .makeId(), true); joinFolder(testFolder, new File(BASEDIR1), new File(BASEDIR2)); final Folder folderAtBart = getContollerBart().getFolderRepository() .getFolder(testFolder); final Folder folderAtLisa = getContollerLisa().getFolderRepository() .getFolder(testFolder); folderAtBart.setSyncProfile(SyncProfile.SYNCHRONIZE_PCS); folderAtLisa.setSyncProfile(SyncProfile.SYNCHRONIZE_PCS); final File testFileBart = TestHelper.createRandomFile(folderAtBart .getLocalBase()); folderAtBart.scanLocalFiles(true); final FileInfo fInfoBart = folderAtBart.getFiles()[0]; TestHelper.waitForCondition(10, new TestHelper.Condition() { public boolean reached() { return folderAtLisa.getFilesCount() >= 1; } }); assertEquals(1, folderAtLisa.getFilesCount()); final FileInfo fInfoLisa = folderAtLisa.getFiles()[0]; final File testFileLisa = fInfoLisa.getDiskFile(getContollerLisa() .getFolderRepository()); assertTrue(fInfoLisa.completelyIdentical(fInfoBart)); assertEquals(testFileBart.length(), testFileLisa.length()); // overwrite file at Bart TestHelper.createTestFile(folderAtBart.getLocalBase(), testFileBart .getName(), new byte[]{6, 5, 6, 7}); folderAtBart.scanLocalFiles(true); TestHelper.waitMilliSeconds(500); TestHelper.waitForCondition(10, new TestHelper.Condition() { public boolean reached() { return fInfoLisa.completelyIdentical(fInfoBart) && (testFileBart.length() == testFileLisa.length()); } }); RecycleBin binAtLisa = getContollerLisa().getRecycleBin(); assertTrue(binAtLisa.isInRecycleBin(fInfoLisa)); assertEquals(1, binAtLisa.countAllRecycledFiles()); FileInfo infoAtLisa = binAtLisa.getAllRecycledFiles().get(0); // add NO reply to overwrite question on restore binAtLisa .setRecycleBinConfirmationHandler(new RecycleBinConfirmationHandlerNo()); assertFalse(binAtLisa.restoreFromRecycleBin(infoAtLisa)); // file should still be in recycle bin assertEquals(1, binAtLisa.countAllRecycledFiles()); // add Yes reply to overwrite question on restore binAtLisa .setRecycleBinConfirmationHandler(new RecycleBinConfirmationHandlerYes()); assertTrue(binAtLisa.restoreFromRecycleBin(infoAtLisa)); assertEquals(0, binAtLisa.countAllRecycledFiles()); TestHelper.waitMilliSeconds(500); TestHelper.waitForCondition(10, new TestHelper.Condition() { public boolean reached() { return fInfoLisa.completelyIdentical(fInfoBart) && (testFileBart.length() == testFileLisa.length()); } }); }
setupTestFolder(SyncProfile.MANUAL_DOWNLOAD);
FolderRepository.USE_NEW_SCANNING_CODE = false; setupTestFolder(SyncProfile.PROJECT_WORK);
public void setUp() throws Exception { super.setUp(); setupTestFolder(SyncProfile.MANUAL_DOWNLOAD); folderScanner = new FolderScanner(getController()); folderScanner.start(); }
orderQtyControl.getTextControl().addListener( SWT.KeyUp, new Listener() { public void handleEvent(Event event) { validateForm(); } }); priceControl.getTextControl().addListener( SWT.KeyUp, new Listener() { public void handleEvent(Event event) { validateForm(); } }); validateForm();
public void createPartControl(Composite parent) { toolkit = new FormToolkit(parent.getDisplay()); form = toolkit.createForm(parent); // form.setText("Stock Order Ticket"); GridLayout layout = new GridLayout(); form.getBody().setLayout(layout); // FIXDataDictionaryManager.loadDictionary(FIXDataDictionaryManager.FIX_4_2_BEGIN_STRING); DataDictionary dict = FIXDataDictionaryManager.getDictionary(); buySellControl = new FIXEnumeratedComposite(form.getBody(), SWT.NONE, toolkit, Side.FIELD, new String[] { "" + Side.BUY, "" + Side.SELL, "" + Side.SELL_SHORT, "" + Side.SELL_SHORT_EXEMPT }); orderQtyControl = new FIXStringComposite(form.getBody(), SWT.NONE, toolkit, OrderQty.FIELD); toolkit.paintBordersFor(orderQtyControl); symbolControl = new FIXStringComposite(form.getBody(), SWT.NONE, toolkit, Symbol.FIELD); toolkit.paintBordersFor(symbolControl); priceControl = new FIXStringComposite(form.getBody(), SWT.NONE, toolkit, Price.FIELD); toolkit.paintBordersFor(priceControl); timeInForceControl = new FIXEnumeratedComposite(form.getBody(), SWT.NONE, toolkit, TimeInForce.FIELD, new String[] { "" + TimeInForce.DAY, "" + TimeInForce.GOOD_TILL_CANCEL, "" + TimeInForce.FILL_OR_KILL, "" + TimeInForce.IMMEDIATE_OR_CANCEL }); timeInForceControl.setSelection("" + TimeInForce.DAY, true); accountControl = new FIXStringComposite(form.getBody(), SWT.NONE, toolkit, Account.FIELD); toolkit.paintBordersFor(accountControl); Composite okCancelComposite = toolkit.createComposite(form.getBody()); okCancelComposite.setLayout(new RowLayout(SWT.HORIZONTAL)); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END); okCancelComposite.setLayoutData(gd); sendButton = toolkit.createButton(okCancelComposite, "Send", SWT.PUSH); cancelButton = toolkit.createButton(okCancelComposite, "Cancel", SWT.PUSH); cancelButton.addMouseListener(new MouseAdapter() { public void mouseUp(MouseEvent e) { handleCancel(); } }); sendButton.addMouseListener(new MouseAdapter() { public void mouseUp(MouseEvent e) { handleSend(); } }); }
validateForm();
protected void handleCancel() { clear(); }
advangedSettingsTab = new AdvancedSettingsTab(getController());
advancedSettingsTab = new AdvancedSettingsTab(getController());
public void initComponents() { mydnsndsModel = new ValueHolder(ConfigurationEntry.DYNDNS_HOSTNAME .getValue(getController())); mydnsndsModel.addValueChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String dyndns = (String) evt.getNewValue(); // show tab when dyndns host is set showDynDNSTab(!StringUtils.isBlank(dyndns)); } }); tabbedPane = new JTabbedPane(JTabbedPane.LEFT); GeneralSettingsTab generalSettingsTab = new GeneralSettingsTab( getController()); preferenceTabs.add(generalSettingsTab); tabbedPane.addTab(" " + generalSettingsTab.getTabName() + " ", null, generalSettingsTab.getUIPanel(), null); NetworkSettingsTab networkSettingsTab = new NetworkSettingsTab( getController(), mydnsndsModel); preferenceTabs.add(networkSettingsTab); tabbedPane.addTab(networkSettingsTab.getTabName(), null, networkSettingsTab.getUIPanel(), null); DialogsSettingsTab dialogsSettingsTab = new DialogsSettingsTab( getController()); preferenceTabs.add(dialogsSettingsTab); tabbedPane.addTab(dialogsSettingsTab.getTabName(), null, dialogsSettingsTab.getUIPanel(), null); PluginSettingsTab pluginSettingsTab = new PluginSettingsTab( getController(), this); if (getController().getPluginManager().countPlugins() > 0) { preferenceTabs.add(pluginSettingsTab); tabbedPane.addTab(pluginSettingsTab.getTabName(), null, pluginSettingsTab.getUIPanel(), null); } showDynDNSTab(!StringUtils.isBlank((String) mydnsndsModel.getValue())); advangedSettingsTab = new AdvancedSettingsTab(getController()); if ("true".equals(getController().getConfig().get( GeneralSettingsTab.SHOWADVANGEDSETTINGS))) { preferenceTabs.add(advangedSettingsTab); tabbedPane.addTab(advangedSettingsTab.getTabName(), null, advangedSettingsTab.getUIPanel(), null); } // Behavior for advanced settings panel generalSettingsTab.getShowAdvancedSettingsModel() .addValueChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { showAdvangedTab(Boolean.TRUE.equals(evt.getNewValue())); } }); showAdvangedTab(Boolean.TRUE.equals(generalSettingsTab .getShowAdvancedSettingsModel().getValue())); tabbedPane.setSelectedIndex(0); tabbedPane.setBorder(Borders.createEmptyBorder("3dlu,0,0,3dlu")); // Buttons okButton = createOKButton(); cancelButton = createCancelButton(); }
GeneralSettingsTab.SHOWADVANGEDSETTINGS)))
GeneralSettingsTab.SHOWADVANCEDSETTINGS)))
public void initComponents() { mydnsndsModel = new ValueHolder(ConfigurationEntry.DYNDNS_HOSTNAME .getValue(getController())); mydnsndsModel.addValueChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String dyndns = (String) evt.getNewValue(); // show tab when dyndns host is set showDynDNSTab(!StringUtils.isBlank(dyndns)); } }); tabbedPane = new JTabbedPane(JTabbedPane.LEFT); GeneralSettingsTab generalSettingsTab = new GeneralSettingsTab( getController()); preferenceTabs.add(generalSettingsTab); tabbedPane.addTab(" " + generalSettingsTab.getTabName() + " ", null, generalSettingsTab.getUIPanel(), null); NetworkSettingsTab networkSettingsTab = new NetworkSettingsTab( getController(), mydnsndsModel); preferenceTabs.add(networkSettingsTab); tabbedPane.addTab(networkSettingsTab.getTabName(), null, networkSettingsTab.getUIPanel(), null); DialogsSettingsTab dialogsSettingsTab = new DialogsSettingsTab( getController()); preferenceTabs.add(dialogsSettingsTab); tabbedPane.addTab(dialogsSettingsTab.getTabName(), null, dialogsSettingsTab.getUIPanel(), null); PluginSettingsTab pluginSettingsTab = new PluginSettingsTab( getController(), this); if (getController().getPluginManager().countPlugins() > 0) { preferenceTabs.add(pluginSettingsTab); tabbedPane.addTab(pluginSettingsTab.getTabName(), null, pluginSettingsTab.getUIPanel(), null); } showDynDNSTab(!StringUtils.isBlank((String) mydnsndsModel.getValue())); advangedSettingsTab = new AdvancedSettingsTab(getController()); if ("true".equals(getController().getConfig().get( GeneralSettingsTab.SHOWADVANGEDSETTINGS))) { preferenceTabs.add(advangedSettingsTab); tabbedPane.addTab(advangedSettingsTab.getTabName(), null, advangedSettingsTab.getUIPanel(), null); } // Behavior for advanced settings panel generalSettingsTab.getShowAdvancedSettingsModel() .addValueChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { showAdvangedTab(Boolean.TRUE.equals(evt.getNewValue())); } }); showAdvangedTab(Boolean.TRUE.equals(generalSettingsTab .getShowAdvancedSettingsModel().getValue())); tabbedPane.setSelectedIndex(0); tabbedPane.setBorder(Borders.createEmptyBorder("3dlu,0,0,3dlu")); // Buttons okButton = createOKButton(); cancelButton = createCancelButton(); }
preferenceTabs.add(advangedSettingsTab); tabbedPane.addTab(advangedSettingsTab.getTabName(), null, advangedSettingsTab.getUIPanel(), null);
preferenceTabs.add(advancedSettingsTab); tabbedPane.addTab(advancedSettingsTab.getTabName(), null, advancedSettingsTab.getUIPanel(), null);
public void initComponents() { mydnsndsModel = new ValueHolder(ConfigurationEntry.DYNDNS_HOSTNAME .getValue(getController())); mydnsndsModel.addValueChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String dyndns = (String) evt.getNewValue(); // show tab when dyndns host is set showDynDNSTab(!StringUtils.isBlank(dyndns)); } }); tabbedPane = new JTabbedPane(JTabbedPane.LEFT); GeneralSettingsTab generalSettingsTab = new GeneralSettingsTab( getController()); preferenceTabs.add(generalSettingsTab); tabbedPane.addTab(" " + generalSettingsTab.getTabName() + " ", null, generalSettingsTab.getUIPanel(), null); NetworkSettingsTab networkSettingsTab = new NetworkSettingsTab( getController(), mydnsndsModel); preferenceTabs.add(networkSettingsTab); tabbedPane.addTab(networkSettingsTab.getTabName(), null, networkSettingsTab.getUIPanel(), null); DialogsSettingsTab dialogsSettingsTab = new DialogsSettingsTab( getController()); preferenceTabs.add(dialogsSettingsTab); tabbedPane.addTab(dialogsSettingsTab.getTabName(), null, dialogsSettingsTab.getUIPanel(), null); PluginSettingsTab pluginSettingsTab = new PluginSettingsTab( getController(), this); if (getController().getPluginManager().countPlugins() > 0) { preferenceTabs.add(pluginSettingsTab); tabbedPane.addTab(pluginSettingsTab.getTabName(), null, pluginSettingsTab.getUIPanel(), null); } showDynDNSTab(!StringUtils.isBlank((String) mydnsndsModel.getValue())); advangedSettingsTab = new AdvancedSettingsTab(getController()); if ("true".equals(getController().getConfig().get( GeneralSettingsTab.SHOWADVANGEDSETTINGS))) { preferenceTabs.add(advangedSettingsTab); tabbedPane.addTab(advangedSettingsTab.getTabName(), null, advangedSettingsTab.getUIPanel(), null); } // Behavior for advanced settings panel generalSettingsTab.getShowAdvancedSettingsModel() .addValueChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { showAdvangedTab(Boolean.TRUE.equals(evt.getNewValue())); } }); showAdvangedTab(Boolean.TRUE.equals(generalSettingsTab .getShowAdvancedSettingsModel().getValue())); tabbedPane.setSelectedIndex(0); tabbedPane.setBorder(Borders.createEmptyBorder("3dlu,0,0,3dlu")); // Buttons okButton = createOKButton(); cancelButton = createCancelButton(); }
showAdvangedTab(Boolean.TRUE.equals(evt.getNewValue()));
showAdvancedTab(Boolean.TRUE.equals(evt.getNewValue()));
public void initComponents() { mydnsndsModel = new ValueHolder(ConfigurationEntry.DYNDNS_HOSTNAME .getValue(getController())); mydnsndsModel.addValueChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String dyndns = (String) evt.getNewValue(); // show tab when dyndns host is set showDynDNSTab(!StringUtils.isBlank(dyndns)); } }); tabbedPane = new JTabbedPane(JTabbedPane.LEFT); GeneralSettingsTab generalSettingsTab = new GeneralSettingsTab( getController()); preferenceTabs.add(generalSettingsTab); tabbedPane.addTab(" " + generalSettingsTab.getTabName() + " ", null, generalSettingsTab.getUIPanel(), null); NetworkSettingsTab networkSettingsTab = new NetworkSettingsTab( getController(), mydnsndsModel); preferenceTabs.add(networkSettingsTab); tabbedPane.addTab(networkSettingsTab.getTabName(), null, networkSettingsTab.getUIPanel(), null); DialogsSettingsTab dialogsSettingsTab = new DialogsSettingsTab( getController()); preferenceTabs.add(dialogsSettingsTab); tabbedPane.addTab(dialogsSettingsTab.getTabName(), null, dialogsSettingsTab.getUIPanel(), null); PluginSettingsTab pluginSettingsTab = new PluginSettingsTab( getController(), this); if (getController().getPluginManager().countPlugins() > 0) { preferenceTabs.add(pluginSettingsTab); tabbedPane.addTab(pluginSettingsTab.getTabName(), null, pluginSettingsTab.getUIPanel(), null); } showDynDNSTab(!StringUtils.isBlank((String) mydnsndsModel.getValue())); advangedSettingsTab = new AdvancedSettingsTab(getController()); if ("true".equals(getController().getConfig().get( GeneralSettingsTab.SHOWADVANGEDSETTINGS))) { preferenceTabs.add(advangedSettingsTab); tabbedPane.addTab(advangedSettingsTab.getTabName(), null, advangedSettingsTab.getUIPanel(), null); } // Behavior for advanced settings panel generalSettingsTab.getShowAdvancedSettingsModel() .addValueChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { showAdvangedTab(Boolean.TRUE.equals(evt.getNewValue())); } }); showAdvangedTab(Boolean.TRUE.equals(generalSettingsTab .getShowAdvancedSettingsModel().getValue())); tabbedPane.setSelectedIndex(0); tabbedPane.setBorder(Borders.createEmptyBorder("3dlu,0,0,3dlu")); // Buttons okButton = createOKButton(); cancelButton = createCancelButton(); }
showAdvangedTab(Boolean.TRUE.equals(generalSettingsTab
showAdvancedTab(Boolean.TRUE.equals(generalSettingsTab
public void initComponents() { mydnsndsModel = new ValueHolder(ConfigurationEntry.DYNDNS_HOSTNAME .getValue(getController())); mydnsndsModel.addValueChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String dyndns = (String) evt.getNewValue(); // show tab when dyndns host is set showDynDNSTab(!StringUtils.isBlank(dyndns)); } }); tabbedPane = new JTabbedPane(JTabbedPane.LEFT); GeneralSettingsTab generalSettingsTab = new GeneralSettingsTab( getController()); preferenceTabs.add(generalSettingsTab); tabbedPane.addTab(" " + generalSettingsTab.getTabName() + " ", null, generalSettingsTab.getUIPanel(), null); NetworkSettingsTab networkSettingsTab = new NetworkSettingsTab( getController(), mydnsndsModel); preferenceTabs.add(networkSettingsTab); tabbedPane.addTab(networkSettingsTab.getTabName(), null, networkSettingsTab.getUIPanel(), null); DialogsSettingsTab dialogsSettingsTab = new DialogsSettingsTab( getController()); preferenceTabs.add(dialogsSettingsTab); tabbedPane.addTab(dialogsSettingsTab.getTabName(), null, dialogsSettingsTab.getUIPanel(), null); PluginSettingsTab pluginSettingsTab = new PluginSettingsTab( getController(), this); if (getController().getPluginManager().countPlugins() > 0) { preferenceTabs.add(pluginSettingsTab); tabbedPane.addTab(pluginSettingsTab.getTabName(), null, pluginSettingsTab.getUIPanel(), null); } showDynDNSTab(!StringUtils.isBlank((String) mydnsndsModel.getValue())); advangedSettingsTab = new AdvancedSettingsTab(getController()); if ("true".equals(getController().getConfig().get( GeneralSettingsTab.SHOWADVANGEDSETTINGS))) { preferenceTabs.add(advangedSettingsTab); tabbedPane.addTab(advangedSettingsTab.getTabName(), null, advangedSettingsTab.getUIPanel(), null); } // Behavior for advanced settings panel generalSettingsTab.getShowAdvancedSettingsModel() .addValueChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { showAdvangedTab(Boolean.TRUE.equals(evt.getNewValue())); } }); showAdvangedTab(Boolean.TRUE.equals(generalSettingsTab .getShowAdvancedSettingsModel().getValue())); tabbedPane.setSelectedIndex(0); tabbedPane.setBorder(Borders.createEmptyBorder("3dlu,0,0,3dlu")); // Buttons okButton = createOKButton(); cancelButton = createCancelButton(); }
showAdvangedTab(Boolean.TRUE.equals(evt.getNewValue()));
showAdvancedTab(Boolean.TRUE.equals(evt.getNewValue()));
public void propertyChange(PropertyChangeEvent evt) { showAdvangedTab(Boolean.TRUE.equals(evt.getNewValue())); }
File netutil = Util.copyResourceTo(LIBRARY + ".dll", "de/dal33t/powerfolder/util/os/Win32", new File("."), true);
Util.copyResourceTo(LIBRARY + ".dll", "de/dal33t/powerfolder/util/os/Win32", new File("."), true);
public static boolean loadLibrary() { try { File netutil = Util.copyResourceTo(LIBRARY + ".dll", "de/dal33t/powerfolder/util/os/Win32", new File("."), true); // do not test for null here. // because if another Pf client is running the dll cannot be // overwritten and the method will return null, but the dll/library // will be there anyway. // if (netutil == null) { // LOG.error("Couldn't load " + LIBRARY); // return false; // } LOG.verbose("Loading library: " + LIBRARY); System.loadLibrary(LIBRARY); return true; } catch (UnsatisfiedLinkError e) { LOG.error(e); // WORKAROUND: For PowerFolder webstart this workaround is // required (FIXME Still needed?) try { File base = new File(Controller.getTempFilesLocation(), LIBRARY); LOG.warn("Loading library (harder): " + base.getAbsolutePath()); System.loadLibrary(base.getAbsolutePath()); return true; } catch (UnsatisfiedLinkError e2) { LOG.error(e2); return false; } } }
LOG.error(e);
LOG.error("loading library step one failed: " + LIBRARY, e);
public static boolean loadLibrary() { try { File netutil = Util.copyResourceTo(LIBRARY + ".dll", "de/dal33t/powerfolder/util/os/Win32", new File("."), true); // do not test for null here. // because if another Pf client is running the dll cannot be // overwritten and the method will return null, but the dll/library // will be there anyway. // if (netutil == null) { // LOG.error("Couldn't load " + LIBRARY); // return false; // } LOG.verbose("Loading library: " + LIBRARY); System.loadLibrary(LIBRARY); return true; } catch (UnsatisfiedLinkError e) { LOG.error(e); // WORKAROUND: For PowerFolder webstart this workaround is // required (FIXME Still needed?) try { File base = new File(Controller.getTempFilesLocation(), LIBRARY); LOG.warn("Loading library (harder): " + base.getAbsolutePath()); System.loadLibrary(base.getAbsolutePath()); return true; } catch (UnsatisfiedLinkError e2) { LOG.error(e2); return false; } } }
LOG.error(e2);
LOG.error("Loading library failed: " + LIBRARY, e2);
public static boolean loadLibrary() { try { File netutil = Util.copyResourceTo(LIBRARY + ".dll", "de/dal33t/powerfolder/util/os/Win32", new File("."), true); // do not test for null here. // because if another Pf client is running the dll cannot be // overwritten and the method will return null, but the dll/library // will be there anyway. // if (netutil == null) { // LOG.error("Couldn't load " + LIBRARY); // return false; // } LOG.verbose("Loading library: " + LIBRARY); System.loadLibrary(LIBRARY); return true; } catch (UnsatisfiedLinkError e) { LOG.error(e); // WORKAROUND: For PowerFolder webstart this workaround is // required (FIXME Still needed?) try { File base = new File(Controller.getTempFilesLocation(), LIBRARY); LOG.warn("Loading library (harder): " + base.getAbsolutePath()); System.loadLibrary(base.getAbsolutePath()); return true; } catch (UnsatisfiedLinkError e2) { LOG.error(e2); return false; } } }
LoggerAdapter.error("Unable to get database IDs from "+mNextID, ex, this);
LoggerAdapter.error(MessageKey.DB_ID_FETCH.getLocalizedMessage(mNextID), ex, this);
public String getNext() throws NoMoreIDsException { synchronized (this) { if (mNextID >= mUpTo) { try { grabIDs(); } catch (SQLException ex) { LoggerAdapter.error("Unable to get database IDs from "+mNextID, ex, this); throw new NoMoreIDsException(ex); } } return "" + (mNextID++); } }
silentModeThrottle = new JSlider(); silentModeThrottle.setMajorTickSpacing(25); silentModeThrottle.setMinorTickSpacing(5); silentModeThrottle.setPaintTicks(true); silentModeThrottle.setPaintLabels(true); int smt = 70; try { smt = Integer.parseInt(getController() .getConfig().getProperty("net.silentmodethrottle")); } catch (NumberFormatException e) { log().debug("silentmodethrottle" + e); } silentModeThrottle.setValue(smt);
private void initComponents() { String[] options = new String[3]; options[PRIVATE_MODE_INDEX] = Translation .getTranslation("preferences.dialog.networkmode.private"); options[PUBLIC_MODE_INDEX] = Translation .getTranslation("preferences.dialog.networkmode.public"); options[LANONLY_MODE_INDEX] = Translation .getTranslation("preferences.dialog.networkmode.lanonly"); networkingMode = new JComboBox(options); if (getController().isLanOnly()) { networkingMode.setSelectedIndex(LANONLY_MODE_INDEX); networkingMode .setToolTipText(Translation .getTranslation("preferences.dialog.networkmode.lanonly.tooltip")); } else if (getController().isPublicNetworking()) { networkingMode.setSelectedIndex(PUBLIC_MODE_INDEX); networkingMode .setToolTipText(Translation .getTranslation("preferences.dialog.networkmode.public.tooltip")); } else { // private networkingMode.setSelectedIndex(PRIVATE_MODE_INDEX); networkingMode .setToolTipText(Translation .getTranslation("preferences.dialog.networkmode.private.tooltip")); } networkingMode.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String tooltip = null; switch (networkingMode.getSelectedIndex()) { case PRIVATE_MODE_INDEX : { tooltip = Translation .getTranslation("preferences.dialog.networkmode.private.tooltip"); break; } case PUBLIC_MODE_INDEX : { tooltip = Translation .getTranslation("preferences.dialog.networkmode.public.tooltip"); break; } case LANONLY_MODE_INDEX : { tooltip = Translation .getTranslation("preferences.dialog.networkmode.lanonly.tooltip"); break; } } networkingMode.setToolTipText(tooltip); } }); // DynDns myDnsLabel = new LinkLabel(Translation .getTranslation("preferences.dialog.dyndns"), Translation .getTranslation("preferences.dialog.dyndns.link")); myDnsField = SimpleComponentFactory .createTextField(mydnsndsModel, true); wanSpeed = new LineSpeedSelectionPanel(); wanSpeed.loadWANSelection(); wanSpeed.setUploadSpeedKBPS(getController().getTransferManager() .getAllowedUploadCPSForWAN() / 1024); lanSpeed = new LineSpeedSelectionPanel(); lanSpeed.loadLANSelection(); lanSpeed.setUploadSpeedKBPS(getController().getTransferManager() .getAllowedUploadCPSForLAN() / 1024); }
getController().getConfig().setProperty("net.silentmodethrottle", Integer.toString(silentModeThrottle.getValue()));
public void save() { Controller.NetworkingMode netMode; switch (networkingMode.getSelectedIndex()) { case 0 : { netMode = NetworkingMode.PRIVATEMODE; break; } case 1 : { netMode = NetworkingMode.PUBLICMODE; break; } case 2 : { netMode = NetworkingMode.LANONLYMODE; break; } default : throw new IllegalStateException("invalid index"); } getController().setNetworkingMode(netMode); getController().getTransferManager().setAllowedUploadCPSForWAN( wanSpeed.getUploadSpeedKBPS()); getController().getTransferManager().setAllowedUploadCPSForLAN( lanSpeed.getUploadSpeedKBPS()); String dyndnsHost = (String) mydnsndsModel.getValue(); Properties config = getController().getConfig(); // remove the dyndns, this is done here because // the save method of "invisible" tabs are not called // and if the mydnsndsModel is empty the dyndns tab is "invisible" if (StringUtils.isBlank(dyndnsHost) && config.containsKey("mydyndns")) { config.remove("mydyndns"); } }
return getController().getPreferences().get("uitheme", null);
return PreferencesEntry.UI_COLOUR_THEME.getValueString(getController());
public String getUIThemeConfig() { return getController().getPreferences().get("uitheme", null); }
System.out.println("Got BP header request from mote " + id);
CompassTools.debugPrintln("Got BP header request from mote " + id);
public void messageReceived(int to, Message m) { UnicastPack pack = (UnicastPack) m; int id = pack.get_data_src(); if (id != owner.getID()) return; switch (pack.get_data_type()) { case CompassMote.BIGPACKHEADER: // If true, this is the initial request, else an ACK. if (!busy && pack.get_data_data_bpHeader_packTotal() == 0) { System.out.println("Got BP header request from mote " + id); type = pack.get_data_data_bpHeader_requestType(); // Build a new BigPack of the requested type BigPack newPack = owner.buildPack(type); if (newPack == null) { System.out.println("BP could not be built for mote " + id + "!"); return; } newMessage(newPack); curPackNum = HEADER_PACK_NUM; sendHeader(); // Send BP header } else if (busy && pack.get_data_data_bpHeader_packTotal() != 0 && curPackNum == HEADER_PACK_NUM && pack.get_data_data_bpHeader_requestType() == type) { System.out.println("Got BP header ack from mote " + id); curPackNum++; sendData(); // Send BP data } break; case CompassMote.BIGPACKDATA: if (busy && pack.get_data_data_bpData_curPack() == curPackNum) { if (morePacksExist()) { System.out.println("Got BP data ack from mote " + id); curPackNum++; sendData(); // Send BP data } else { System.out.println("BP sent to mote " + id + " complete"); busy = false; owner.packerDone(type); // Done! } } break; } }
System.out.println("BP could not be built for mote " + id + "!");
CompassTools.debugPrintln("BP could not be built for mote " + id + "!");
public void messageReceived(int to, Message m) { UnicastPack pack = (UnicastPack) m; int id = pack.get_data_src(); if (id != owner.getID()) return; switch (pack.get_data_type()) { case CompassMote.BIGPACKHEADER: // If true, this is the initial request, else an ACK. if (!busy && pack.get_data_data_bpHeader_packTotal() == 0) { System.out.println("Got BP header request from mote " + id); type = pack.get_data_data_bpHeader_requestType(); // Build a new BigPack of the requested type BigPack newPack = owner.buildPack(type); if (newPack == null) { System.out.println("BP could not be built for mote " + id + "!"); return; } newMessage(newPack); curPackNum = HEADER_PACK_NUM; sendHeader(); // Send BP header } else if (busy && pack.get_data_data_bpHeader_packTotal() != 0 && curPackNum == HEADER_PACK_NUM && pack.get_data_data_bpHeader_requestType() == type) { System.out.println("Got BP header ack from mote " + id); curPackNum++; sendData(); // Send BP data } break; case CompassMote.BIGPACKDATA: if (busy && pack.get_data_data_bpData_curPack() == curPackNum) { if (morePacksExist()) { System.out.println("Got BP data ack from mote " + id); curPackNum++; sendData(); // Send BP data } else { System.out.println("BP sent to mote " + id + " complete"); busy = false; owner.packerDone(type); // Done! } } break; } }
System.out.println("Got BP header ack from mote " + id);
CompassTools.debugPrintln("Got BP header ack from mote " + id);
public void messageReceived(int to, Message m) { UnicastPack pack = (UnicastPack) m; int id = pack.get_data_src(); if (id != owner.getID()) return; switch (pack.get_data_type()) { case CompassMote.BIGPACKHEADER: // If true, this is the initial request, else an ACK. if (!busy && pack.get_data_data_bpHeader_packTotal() == 0) { System.out.println("Got BP header request from mote " + id); type = pack.get_data_data_bpHeader_requestType(); // Build a new BigPack of the requested type BigPack newPack = owner.buildPack(type); if (newPack == null) { System.out.println("BP could not be built for mote " + id + "!"); return; } newMessage(newPack); curPackNum = HEADER_PACK_NUM; sendHeader(); // Send BP header } else if (busy && pack.get_data_data_bpHeader_packTotal() != 0 && curPackNum == HEADER_PACK_NUM && pack.get_data_data_bpHeader_requestType() == type) { System.out.println("Got BP header ack from mote " + id); curPackNum++; sendData(); // Send BP data } break; case CompassMote.BIGPACKDATA: if (busy && pack.get_data_data_bpData_curPack() == curPackNum) { if (morePacksExist()) { System.out.println("Got BP data ack from mote " + id); curPackNum++; sendData(); // Send BP data } else { System.out.println("BP sent to mote " + id + " complete"); busy = false; owner.packerDone(type); // Done! } } break; } }
System.out.println("Got BP data ack from mote " + id);
CompassTools.debugPrintln("Got BP data ack from mote " + id);
public void messageReceived(int to, Message m) { UnicastPack pack = (UnicastPack) m; int id = pack.get_data_src(); if (id != owner.getID()) return; switch (pack.get_data_type()) { case CompassMote.BIGPACKHEADER: // If true, this is the initial request, else an ACK. if (!busy && pack.get_data_data_bpHeader_packTotal() == 0) { System.out.println("Got BP header request from mote " + id); type = pack.get_data_data_bpHeader_requestType(); // Build a new BigPack of the requested type BigPack newPack = owner.buildPack(type); if (newPack == null) { System.out.println("BP could not be built for mote " + id + "!"); return; } newMessage(newPack); curPackNum = HEADER_PACK_NUM; sendHeader(); // Send BP header } else if (busy && pack.get_data_data_bpHeader_packTotal() != 0 && curPackNum == HEADER_PACK_NUM && pack.get_data_data_bpHeader_requestType() == type) { System.out.println("Got BP header ack from mote " + id); curPackNum++; sendData(); // Send BP data } break; case CompassMote.BIGPACKDATA: if (busy && pack.get_data_data_bpData_curPack() == curPackNum) { if (morePacksExist()) { System.out.println("Got BP data ack from mote " + id); curPackNum++; sendData(); // Send BP data } else { System.out.println("BP sent to mote " + id + " complete"); busy = false; owner.packerDone(type); // Done! } } break; } }
System.out.println("BP sent to mote " + id + " complete");
CompassTools.debugPrintln("BP sent to mote " + id + " complete");
public void messageReceived(int to, Message m) { UnicastPack pack = (UnicastPack) m; int id = pack.get_data_src(); if (id != owner.getID()) return; switch (pack.get_data_type()) { case CompassMote.BIGPACKHEADER: // If true, this is the initial request, else an ACK. if (!busy && pack.get_data_data_bpHeader_packTotal() == 0) { System.out.println("Got BP header request from mote " + id); type = pack.get_data_data_bpHeader_requestType(); // Build a new BigPack of the requested type BigPack newPack = owner.buildPack(type); if (newPack == null) { System.out.println("BP could not be built for mote " + id + "!"); return; } newMessage(newPack); curPackNum = HEADER_PACK_NUM; sendHeader(); // Send BP header } else if (busy && pack.get_data_data_bpHeader_packTotal() != 0 && curPackNum == HEADER_PACK_NUM && pack.get_data_data_bpHeader_requestType() == type) { System.out.println("Got BP header ack from mote " + id); curPackNum++; sendData(); // Send BP data } break; case CompassMote.BIGPACKDATA: if (busy && pack.get_data_data_bpData_curPack() == curPackNum) { if (morePacksExist()) { System.out.println("Got BP data ack from mote " + id); curPackNum++; sendData(); // Send BP data } else { System.out.println("BP sent to mote " + id + " complete"); busy = false; owner.packerDone(type); // Done! } } break; } }
System.out.println("Sent BP data (" + (curPackNum + 1) + "/" + numPacks
CompassTools.debugPrintln("Sent BP data (" + (curPackNum + 1) + "/" + numPacks
private void sendData() { UnicastPack pack = new UnicastPack(); pack.set_data_type(BigPack.BIGPACKDATA); pack.set_data_data_bpData_curPack(curPackNum); int firstByte = curPackNum * BigPack.BP_DATA_LEN; int length = BigPack.BP_DATA_LEN; if ((firstByte + length) > stream.length) length = stream.length - firstByte; pack.set_data_data_bpData_data(byteRange(firstByte, length)); try { owner.sendPack(pack); System.out.println("Sent BP data (" + (curPackNum + 1) + "/" + numPacks + ") to mote " + owner.getID()); } catch (IOException e) { e.printStackTrace(); } }
System.out.println("Sent BP header (0/" + numPacks + ") to mote "
CompassTools.debugPrintln("Sent BP header (0/" + numPacks + ") to mote "
private void sendHeader() { UnicastPack pack = new UnicastPack(); pack.set_data_type(BigPack.BIGPACKHEADER); pack.set_data_data_bpHeader_requestType(type); pack.set_data_data_bpHeader_packTotal((short) numPacks); pack.set_data_data_bpHeader_byteTotal(stream.length); pack.set_data_data_bpHeader_numBlocks((short) numBlocks); pack.set_data_data_bpHeader_numPtrs((short) numPtrs); try { owner.sendPack(pack); System.out.println("Sent BP header (0/" + numPacks + ") to mote " + owner.getID()); } catch (IOException e) { e.printStackTrace(); } }
MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Run script", "We're running!");
IScript script = new Script("puts 'sample script output'"); BSFManager manager = new BSFManager(); ScriptRunnable runnable = new ScriptRunnable(script, manager); runnable.run();
public void run(IAction action) { MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Run script", "We're running!"); //agl todo:temp }
this.targetEditor = targetEditor;
public void setActiveEditor(IAction action, IEditorPart targetEditor) { // TODO Auto-generated method stub }
if (na.getMask().sameSubnet(addr, na.getAddress()))
if (na.isValid() && na.getMask().sameSubnet(addr, na.getAddress())) {
public static boolean isOnAnySubnet(Inet4Address addr) { if (localAddresses == null) { NetworkHelper nh = NetworkHelper.getInstance(); if (nh == null) { LOG.verbose("Subnet test not supported on this platform."); return false; } localAddresses = nh.getNetworkAddresses(); } for (NetworkAddress na: localAddresses) { if (na.getMask().sameSubnet(addr, na.getAddress())) return true; } return false; }
}
public static boolean isOnAnySubnet(Inet4Address addr) { if (localAddresses == null) { NetworkHelper nh = NetworkHelper.getInstance(); if (nh == null) { LOG.verbose("Subnet test not supported on this platform."); return false; } localAddresses = nh.getNetworkAddresses(); } for (NetworkAddress na: localAddresses) { if (na.getMask().sameSubnet(addr, na.getAddress())) return true; } return false; }
port.addEntry(entry);
public void testGetProgress() { Portfolio port = new Portfolio(null, PORTFOLIO_NAME); PositionEntry entry = new PositionEntry(port, "NAME", new InternalID( "1234")); Message aMessage = FIXMessageUtil.newExecutionReport(new InternalID("1234"), new InternalID("456"), "987", ExecTransType.STATUS, ExecType.PARTIAL_FILL, OrdStatus.PARTIALLY_FILLED, Side.BUY, new BigDecimal(1000), new BigDecimal("12.3"), new BigDecimal(500), new BigDecimal("12.3"), new BigDecimal(500), new BigDecimal(500), new BigDecimal("12.3"), "IBM"); entry.addIncomingMessage(aMessage); assertEquals(.5, entry.getProgress(), .001); assertEquals(.5, port.getProgress(), .001); Message aMessage2 = FIXMessageUtil.newExecutionReport(new InternalID("9876"), new InternalID("876"), "567", ExecTransType.STATUS, ExecType.PARTIAL_FILL, OrdStatus.PARTIALLY_FILLED, Side.BUY, new BigDecimal(1000), new BigDecimal("12.3"), new BigDecimal(500), new BigDecimal("12.3"), new BigDecimal(500), new BigDecimal(500), new BigDecimal("12.3"), "IBM"); entry.addIncomingMessage(aMessage2); assertEquals(.5, entry.getProgress(), .001); assertEquals(.5, port.getProgress(), .001); }
long totalSizeUploadingTo = uploadingToSize(upload
long totalPlannedSizeUploadingTo = uploadingToSize(upload
private void checkQueuedUploads() { // Check uploads to start List<Upload> uploadsToStart = new LinkedList<Upload>(); Map<Member, Long> uploadSizeToStartNodes = new HashMap<Member, Long>(); List<Upload> uploadsToBreak = new ArrayList<Upload>(); if (logVerbose) { log().verbose( "Checking " + queuedUploads.size() + " queued uploads"); } synchronized (queuedUploads) { for (Iterator it = queuedUploads.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); if (upload.isBroken()) { // add to break dls uploadsToBreak.add(upload); } else if (hasFreeUploadSlots() || upload.getPartner().isOnLAN()) { // The total size planned+current uploading to that node. long totalSizeUploadingTo = uploadingToSize(upload .getPartner()); if (totalSizeUploadingTo < 0) { totalSizeUploadingTo = 0; } Long plannedSizeUploadingTo = uploadSizeToStartNodes .get(upload.getPartner()); if (plannedSizeUploadingTo != null) { totalSizeUploadingTo += plannedSizeUploadingTo .longValue(); } if (totalSizeUploadingTo <= 5 * 1024 * 1024) { if (totalSizeUploadingTo >= 0) { log() .warn( "Starting another upload to " + upload.getPartner().getNick() + ". Total size to upload to: " + Format .formatBytesShort(totalSizeUploadingTo)); } // start the upload if we have free slots // and not uploading to member currently // or user is on local network // TODO should check if this file is not sended (or is // being send) to other user in the last minute or so to // allow for disitributtion of that file by user that // just received that file from us // Enqueue upload to friends and lan members first int uploadIndex = upload.getPartner().isFriend() ? 0 : uploadsToStart.size(); log() .verbose( "Starting upload at queue position: " + uploadIndex); uploadsToStart.add(uploadIndex, upload); uploadSizeToStartNodes.put(upload.getPartner(), Long .valueOf(upload.getFile().getSize())); } } } } if (logVerbose) { log().verbose( "Starting " + uploadsToStart.size() + " Uploads, " + uploadsToBreak.size() + " are getting broken"); } // Start uploads for (Iterator it = uploadsToStart.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); upload.start(); } for (Iterator it = uploadsToBreak.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); // Set broken setBroken(upload); } }
if (totalSizeUploadingTo < 0) { totalSizeUploadingTo = 0;
if (totalPlannedSizeUploadingTo < 0) { totalPlannedSizeUploadingTo = 0;
private void checkQueuedUploads() { // Check uploads to start List<Upload> uploadsToStart = new LinkedList<Upload>(); Map<Member, Long> uploadSizeToStartNodes = new HashMap<Member, Long>(); List<Upload> uploadsToBreak = new ArrayList<Upload>(); if (logVerbose) { log().verbose( "Checking " + queuedUploads.size() + " queued uploads"); } synchronized (queuedUploads) { for (Iterator it = queuedUploads.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); if (upload.isBroken()) { // add to break dls uploadsToBreak.add(upload); } else if (hasFreeUploadSlots() || upload.getPartner().isOnLAN()) { // The total size planned+current uploading to that node. long totalSizeUploadingTo = uploadingToSize(upload .getPartner()); if (totalSizeUploadingTo < 0) { totalSizeUploadingTo = 0; } Long plannedSizeUploadingTo = uploadSizeToStartNodes .get(upload.getPartner()); if (plannedSizeUploadingTo != null) { totalSizeUploadingTo += plannedSizeUploadingTo .longValue(); } if (totalSizeUploadingTo <= 5 * 1024 * 1024) { if (totalSizeUploadingTo >= 0) { log() .warn( "Starting another upload to " + upload.getPartner().getNick() + ". Total size to upload to: " + Format .formatBytesShort(totalSizeUploadingTo)); } // start the upload if we have free slots // and not uploading to member currently // or user is on local network // TODO should check if this file is not sended (or is // being send) to other user in the last minute or so to // allow for disitributtion of that file by user that // just received that file from us // Enqueue upload to friends and lan members first int uploadIndex = upload.getPartner().isFriend() ? 0 : uploadsToStart.size(); log() .verbose( "Starting upload at queue position: " + uploadIndex); uploadsToStart.add(uploadIndex, upload); uploadSizeToStartNodes.put(upload.getPartner(), Long .valueOf(upload.getFile().getSize())); } } } } if (logVerbose) { log().verbose( "Starting " + uploadsToStart.size() + " Uploads, " + uploadsToBreak.size() + " are getting broken"); } // Start uploads for (Iterator it = uploadsToStart.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); upload.start(); } for (Iterator it = uploadsToBreak.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); // Set broken setBroken(upload); } }
totalSizeUploadingTo += plannedSizeUploadingTo
totalPlannedSizeUploadingTo += plannedSizeUploadingTo
private void checkQueuedUploads() { // Check uploads to start List<Upload> uploadsToStart = new LinkedList<Upload>(); Map<Member, Long> uploadSizeToStartNodes = new HashMap<Member, Long>(); List<Upload> uploadsToBreak = new ArrayList<Upload>(); if (logVerbose) { log().verbose( "Checking " + queuedUploads.size() + " queued uploads"); } synchronized (queuedUploads) { for (Iterator it = queuedUploads.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); if (upload.isBroken()) { // add to break dls uploadsToBreak.add(upload); } else if (hasFreeUploadSlots() || upload.getPartner().isOnLAN()) { // The total size planned+current uploading to that node. long totalSizeUploadingTo = uploadingToSize(upload .getPartner()); if (totalSizeUploadingTo < 0) { totalSizeUploadingTo = 0; } Long plannedSizeUploadingTo = uploadSizeToStartNodes .get(upload.getPartner()); if (plannedSizeUploadingTo != null) { totalSizeUploadingTo += plannedSizeUploadingTo .longValue(); } if (totalSizeUploadingTo <= 5 * 1024 * 1024) { if (totalSizeUploadingTo >= 0) { log() .warn( "Starting another upload to " + upload.getPartner().getNick() + ". Total size to upload to: " + Format .formatBytesShort(totalSizeUploadingTo)); } // start the upload if we have free slots // and not uploading to member currently // or user is on local network // TODO should check if this file is not sended (or is // being send) to other user in the last minute or so to // allow for disitributtion of that file by user that // just received that file from us // Enqueue upload to friends and lan members first int uploadIndex = upload.getPartner().isFriend() ? 0 : uploadsToStart.size(); log() .verbose( "Starting upload at queue position: " + uploadIndex); uploadsToStart.add(uploadIndex, upload); uploadSizeToStartNodes.put(upload.getPartner(), Long .valueOf(upload.getFile().getSize())); } } } } if (logVerbose) { log().verbose( "Starting " + uploadsToStart.size() + " Uploads, " + uploadsToBreak.size() + " are getting broken"); } // Start uploads for (Iterator it = uploadsToStart.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); upload.start(); } for (Iterator it = uploadsToBreak.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); // Set broken setBroken(upload); } }
if (totalSizeUploadingTo <= 5 * 1024 * 1024) { if (totalSizeUploadingTo >= 0) {
if (totalPlannedSizeUploadingTo <= 5 * 1024 * 1024) { if (totalPlannedSizeUploadingTo >= 0) {
private void checkQueuedUploads() { // Check uploads to start List<Upload> uploadsToStart = new LinkedList<Upload>(); Map<Member, Long> uploadSizeToStartNodes = new HashMap<Member, Long>(); List<Upload> uploadsToBreak = new ArrayList<Upload>(); if (logVerbose) { log().verbose( "Checking " + queuedUploads.size() + " queued uploads"); } synchronized (queuedUploads) { for (Iterator it = queuedUploads.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); if (upload.isBroken()) { // add to break dls uploadsToBreak.add(upload); } else if (hasFreeUploadSlots() || upload.getPartner().isOnLAN()) { // The total size planned+current uploading to that node. long totalSizeUploadingTo = uploadingToSize(upload .getPartner()); if (totalSizeUploadingTo < 0) { totalSizeUploadingTo = 0; } Long plannedSizeUploadingTo = uploadSizeToStartNodes .get(upload.getPartner()); if (plannedSizeUploadingTo != null) { totalSizeUploadingTo += plannedSizeUploadingTo .longValue(); } if (totalSizeUploadingTo <= 5 * 1024 * 1024) { if (totalSizeUploadingTo >= 0) { log() .warn( "Starting another upload to " + upload.getPartner().getNick() + ". Total size to upload to: " + Format .formatBytesShort(totalSizeUploadingTo)); } // start the upload if we have free slots // and not uploading to member currently // or user is on local network // TODO should check if this file is not sended (or is // being send) to other user in the last minute or so to // allow for disitributtion of that file by user that // just received that file from us // Enqueue upload to friends and lan members first int uploadIndex = upload.getPartner().isFriend() ? 0 : uploadsToStart.size(); log() .verbose( "Starting upload at queue position: " + uploadIndex); uploadsToStart.add(uploadIndex, upload); uploadSizeToStartNodes.put(upload.getPartner(), Long .valueOf(upload.getFile().getSize())); } } } } if (logVerbose) { log().verbose( "Starting " + uploadsToStart.size() + " Uploads, " + uploadsToBreak.size() + " are getting broken"); } // Start uploads for (Iterator it = uploadsToStart.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); upload.start(); } for (Iterator it = uploadsToBreak.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); // Set broken setBroken(upload); } }
.formatBytesShort(totalSizeUploadingTo));
.formatBytesShort(totalPlannedSizeUploadingTo));
private void checkQueuedUploads() { // Check uploads to start List<Upload> uploadsToStart = new LinkedList<Upload>(); Map<Member, Long> uploadSizeToStartNodes = new HashMap<Member, Long>(); List<Upload> uploadsToBreak = new ArrayList<Upload>(); if (logVerbose) { log().verbose( "Checking " + queuedUploads.size() + " queued uploads"); } synchronized (queuedUploads) { for (Iterator it = queuedUploads.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); if (upload.isBroken()) { // add to break dls uploadsToBreak.add(upload); } else if (hasFreeUploadSlots() || upload.getPartner().isOnLAN()) { // The total size planned+current uploading to that node. long totalSizeUploadingTo = uploadingToSize(upload .getPartner()); if (totalSizeUploadingTo < 0) { totalSizeUploadingTo = 0; } Long plannedSizeUploadingTo = uploadSizeToStartNodes .get(upload.getPartner()); if (plannedSizeUploadingTo != null) { totalSizeUploadingTo += plannedSizeUploadingTo .longValue(); } if (totalSizeUploadingTo <= 5 * 1024 * 1024) { if (totalSizeUploadingTo >= 0) { log() .warn( "Starting another upload to " + upload.getPartner().getNick() + ". Total size to upload to: " + Format .formatBytesShort(totalSizeUploadingTo)); } // start the upload if we have free slots // and not uploading to member currently // or user is on local network // TODO should check if this file is not sended (or is // being send) to other user in the last minute or so to // allow for disitributtion of that file by user that // just received that file from us // Enqueue upload to friends and lan members first int uploadIndex = upload.getPartner().isFriend() ? 0 : uploadsToStart.size(); log() .verbose( "Starting upload at queue position: " + uploadIndex); uploadsToStart.add(uploadIndex, upload); uploadSizeToStartNodes.put(upload.getPartner(), Long .valueOf(upload.getFile().getSize())); } } } } if (logVerbose) { log().verbose( "Starting " + uploadsToStart.size() + " Uploads, " + uploadsToBreak.size() + " are getting broken"); } // Start uploads for (Iterator it = uploadsToStart.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); upload.start(); } for (Iterator it = uploadsToBreak.iterator(); it.hasNext();) { Upload upload = (Upload) it.next(); // Set broken setBroken(upload); } }
suite.addTestSuite(LexerTest.class); suite.addTestSuite(ScriptRegistryTest.class);
public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(StockOrderTicketViewTest.class); suite.addTestSuite(FIXMessagesViewTest.class); suite.addTestSuite(FillsViewTest.class); suite.addTestSuite(AveragePricesViewTest.class); suite.addTestSuite(ParserTest.class); return suite; }
Object target = getUIController().getInformationQuarter()
Object displayTarget = getUIController().getInformationQuarter()
public void selectionChanged(SelectionChangeEvent event) { Object[] selections = getSelectionModel().getSelections(); Object target = getUIController().getInformationQuarter() .getDisplayTarget(); final Folder folder; if (target instanceof Directory) { folder = ((Directory) target).getRootFolder(); } else if (target instanceof Folder) { folder = (Folder) target; } else { log().warn( "Unable to mark file for auto download files on target: " + target); return; } if (selections != null && selections.length != 0) { setEnabled(true); doNotAutoDownloadJCheckBoxMenuItem.setSelected(false); boolean setValueTrue = false; // detect different status boolean setValueFalse = false; // detect different status // uses some complex checks to make sure we dont have // conflicting status of files/dirs. only set this menu item to // enable if all are the same. for (Object selection : selections) { if (selection instanceof FileInfo) { FileInfo fileInfo = (FileInfo) selection; if (fileInfo.diskFileExists(getController())) { setEnabled(false); break; } else if (folder.isInBlacklist(fileInfo)) { if (setValueFalse) { setEnabled(false); doNotAutoDownloadJCheckBoxMenuItem .setSelected(false); break; } doNotAutoDownloadJCheckBoxMenuItem .setSelected(true); setValueTrue = true; } else { // detect differnt status setValueFalse = true; if (setValueTrue) { setEnabled(false); doNotAutoDownloadJCheckBoxMenuItem .setSelected(false); break; } } } else if (selection instanceof Directory) { Directory directory = (Directory) selection; if (!directory.isExpected(getController() .getFolderRepository())) { setEnabled(false); break; } else if (folder.isInBlacklist(directory .getFilesRecursive())) { // detect differnt status: if (setValueFalse) { setEnabled(false); doNotAutoDownloadJCheckBoxMenuItem .setSelected(false); break; } doNotAutoDownloadJCheckBoxMenuItem .setSelected(true); setValueTrue = true; } else { // detect differnt status setValueFalse = true; if (setValueTrue) { setEnabled(false); doNotAutoDownloadJCheckBoxMenuItem .setSelected(false); break; } } } else { setEnabled(false); break; } } } }
if (target instanceof Directory) { folder = ((Directory) target).getRootFolder(); } else if (target instanceof Folder) { folder = (Folder) target; } else { log().warn( "Unable to mark file for auto download files on target: " + target);
if (displayTarget instanceof Directory) { folder = ((Directory) displayTarget).getRootFolder(); } else if (displayTarget instanceof Folder) { folder = (Folder) displayTarget; } else {
public void selectionChanged(SelectionChangeEvent event) { Object[] selections = getSelectionModel().getSelections(); Object target = getUIController().getInformationQuarter() .getDisplayTarget(); final Folder folder; if (target instanceof Directory) { folder = ((Directory) target).getRootFolder(); } else if (target instanceof Folder) { folder = (Folder) target; } else { log().warn( "Unable to mark file for auto download files on target: " + target); return; } if (selections != null && selections.length != 0) { setEnabled(true); doNotAutoDownloadJCheckBoxMenuItem.setSelected(false); boolean setValueTrue = false; // detect different status boolean setValueFalse = false; // detect different status // uses some complex checks to make sure we dont have // conflicting status of files/dirs. only set this menu item to // enable if all are the same. for (Object selection : selections) { if (selection instanceof FileInfo) { FileInfo fileInfo = (FileInfo) selection; if (fileInfo.diskFileExists(getController())) { setEnabled(false); break; } else if (folder.isInBlacklist(fileInfo)) { if (setValueFalse) { setEnabled(false); doNotAutoDownloadJCheckBoxMenuItem .setSelected(false); break; } doNotAutoDownloadJCheckBoxMenuItem .setSelected(true); setValueTrue = true; } else { // detect differnt status setValueFalse = true; if (setValueTrue) { setEnabled(false); doNotAutoDownloadJCheckBoxMenuItem .setSelected(false); break; } } } else if (selection instanceof Directory) { Directory directory = (Directory) selection; if (!directory.isExpected(getController() .getFolderRepository())) { setEnabled(false); break; } else if (folder.isInBlacklist(directory .getFilesRecursive())) { // detect differnt status: if (setValueFalse) { setEnabled(false); doNotAutoDownloadJCheckBoxMenuItem .setSelected(false); break; } doNotAutoDownloadJCheckBoxMenuItem .setSelected(true); setValueTrue = true; } else { // detect differnt status setValueFalse = true; if (setValueTrue) { setEnabled(false); doNotAutoDownloadJCheckBoxMenuItem .setSelected(false); break; } } } else { setEnabled(false); break; } } } }
File debugFile = new File("debug/" + targetFolder.getName()
File debugFile = new File(Logger.getDebugDir(), targetFolder.getName()
public void handleMessage(Message message) { if (message == null) { throw new NullPointerException( "Unable to handle message, message is null"); } // related folder is filled if message is a folder related message FolderInfo targetedFolderInfo = null; Folder targetFolder = null; if (message instanceof FolderRelatedMessage) { targetedFolderInfo = ((FolderRelatedMessage) message).folder; targetFolder = getController().getFolderRepository().getFolder( targetedFolderInfo); } // do all the message processing // Processing of message also should take only // a short time, because member is not able // to received any other message meanwhile ! // Identity is not handled HERE ! if (message instanceof FolderList) { FolderList fList = (FolderList) message; lastFolderList = fList; joinToLocalFolders(fList); // Notify waiting ppl synchronized (folderListWaiter) { folderListWaiter.notifyAll(); } // Inform folder repo getController().getFolderRepository().receivedFolderList(this, fList); } else if (message instanceof RequestNetworkFolderList) { RequestNetworkFolderList request = (RequestNetworkFolderList) message; // Answer request for network folder list if (request.completeList()) { sendMessagesAsynchron(NetworkFolderList .createNetworkFolderLists(getController() .getFolderRepository())); } else { sendMessagesAsynchron(NetworkFolderList .createNetworkFolderLists(getController() .getFolderRepository(), request.folders)); } } else if (message instanceof NetworkFolderList) { NetworkFolderList netFolderList = (NetworkFolderList) message; // Inform repo getController().getFolderRepository().receivedNetworkFolderList( this, netFolderList); } else if (message instanceof RequestFileList) { if (targetFolder != null && !targetFolder.isSecret()) { // a file list of a folder if (logVerbose) { log().verbose( targetFolder + ": Sending new filelist to " + this); } sendMessagesAsynchron(FileList .createFileListMessages(targetFolder)); } else { // Send folder not found if not found or folder is secret sendMessageAsynchron(new Problem("Folder not found: " + targetedFolderInfo, false), null); } } else if (message instanceof RequestDownload) { // a download is requested RequestDownload dlReq = (RequestDownload) message; getController().getTransferManager().queueUpload(this, dlReq); } else if (message instanceof DownloadQueued) { // set queued flag here, if we received status from other side DownloadQueued dlQueued = (DownloadQueued) message; getController().getTransferManager().setQueued(dlQueued); } else if (message instanceof AbortDownload) { AbortDownload abort = (AbortDownload) message; // Abort the upload getController().getTransferManager().abortUpload(abort.file, this); } else if (message instanceof FileChunk) { // File chunk received FileChunk chunk = (FileChunk) message; getController().getTransferManager().chunkReceived(chunk, this); } else if (message instanceof RequestNodeList) { // Nodemanager will handle that RequestNodeList request = (RequestNodeList) message; getController().getNodeManager().receivedRequestNodeList(request, this); } else if (message instanceof KnownNodes) { KnownNodes newNodes = (KnownNodes) message; // TODO Move this code into NodeManager.receivedKnownNodes(....) if (isMaster()) { // Set friendship setFriend(true); log().verbose("Syncing friendlist with master"); } // This might also just be a search result and thus not include us // mutalFriend = false; for (int i = 0; i < newNodes.nodes.length; i++) { MemberInfo remoteNodeInfo = newNodes.nodes[i]; if (remoteNodeInfo == null) { continue; } if (getInfo().equals(remoteNodeInfo)) { // Take his info updateInfo(remoteNodeInfo); } if (remoteNodeInfo .equals(getController().getMySelf().getInfo())) { // Check for mutal friendship mutalFriend = remoteNodeInfo.isFriend; } // Syncing friendlist with master if (isMaster()) { Member node = remoteNodeInfo.getNode(getController(), true); node.setFriend(remoteNodeInfo.isFriend); } } // Queue arrived node list at nodemanager getController().getNodeManager().queueNewNodes(newNodes.nodes); } else if (message instanceof RequestNodeInformation) { // send him our node information sendMessageAsynchron(new NodeInformation(getController()), null); } else if (message instanceof TransferStatus) { // Hold transfer status lastTransferStatus = (TransferStatus) message; } else if (message instanceof NodeInformation) { if (logVerbose) { log().verbose("Node information received"); } if (Logger.isLogToFileEnabled()) { Debug.writeNodeInformation((NodeInformation) message); } // Cache the last node information // lastNodeInformation = (NodeInformation) message; } else if (message instanceof SettingsChange) { SettingsChange settingsChange = (SettingsChange) message; if (settingsChange.newInfo != null) { log().debug( this.getInfo().nick + " changed nick to " + settingsChange.newInfo.nick); setNick(settingsChange.newInfo.nick); } } else if (message instanceof FileList) { FileList remoteFileList = (FileList) message; if (logVerbose) { log().verbose( remoteFileList.folder + ": Received new filelist (" + remoteFileList.folder.filesCount + " file(s)) from " + this); } // Add filelist to filelist cache Map<FileInfo, FileInfo> cachedFileList = Collections .synchronizedMap(new HashMap<FileInfo, FileInfo>( remoteFileList.files.length)); for (int i = 0; i < remoteFileList.files.length; i++) { cachedFileList.put(remoteFileList.files[i], remoteFileList.files[i]); } lastFiles.put(remoteFileList.folder, cachedFileList); // Trigger requesting if (targetFolder != null) { // Write filelist if (Logger.isLogToFileEnabled()) { // Write filelist to disk File debugFile = new File("debug/" + targetFolder.getName() + "/" + getNick() + ".list.txt"); Debug.writeFileList(cachedFileList.keySet(), "FileList of folder " + targetFolder.getName() + ", member " + this + ":", debugFile); } // Inform folder targetFolder.fileListChanged(this, remoteFileList); } } else if (message instanceof FolderFilesChanged) { if (logVerbose) { log().debug("FileListChange received: " + message); } FolderFilesChanged changes = (FolderFilesChanged) message; // Correct filelist Map<FileInfo, FileInfo> cachedFileList = getLastFileList0(changes.folder); if (cachedFileList == null) { log().warn( "Received folder changes on " + changes.folder.name + ", but not received the full filelist"); return; } synchronized (cachedFileList) { if (changes.added != null) { for (int i = 0; i < changes.added.length; i++) { FileInfo file = changes.added[i]; cachedFileList.remove(file); cachedFileList.put(file, file); } } if (changes.modified != null) { for (int i = 0; i < changes.modified.length; i++) { FileInfo file = changes.modified[i]; cachedFileList.remove(file); cachedFileList.put(file, file); } } if (changes.removed != null) { for (int i = 0; i < changes.removed.length; i++) { FileInfo file = changes.removed[i]; cachedFileList.remove(file); cachedFileList.put(file, file); // file removed so if downloading break the download TransferManager tm = getController() .getTransferManager(); if (tm.isDownloadingFileFrom(file, this)) { if (logVerbose) { log().verbose( "downloading removed file breaking it! " + file + " " + this); } tm.abortDownload(file, this); } } } } if (targetFolder != null) { // Write filelist if (Logger.isLogToFileEnabled()) { // Write filelist to disk File debugFile = new File("debug/" + targetFolder.getName() + "/" + getNick() + ".list.txt"); Debug.writeFileList(cachedFileList.keySet(), "FileList of folder " + targetFolder.getName() + ", member " + this + ":", debugFile); } // Inform folder targetFolder.fileListChanged(this, changes); } } else if (message instanceof Invitation) { // Invitation to folder Invitation invitation = (Invitation) message; // To ensure invitor is correct invitation.invitor = this.getInfo(); getController().getFolderRepository().invitationReceived( invitation, true, false); } else if (message instanceof Problem) { Problem problem = (Problem) message; if (problem.problemCode == Problem.YOU_ARE_BORING) { // Finds us boring // set unable to connect log().debug("Node finds us boring, not longer connect"); unableToConnect = true; // Not connected to public network isConnectedToNetwork = true; } else { log().warn("Problem received: " + problem); } if (problem.fatal) { // Shutdown shutdown(); } } else if (message instanceof SearchNodeRequest) { // Send nodelist that matches the search. final SearchNodeRequest request = (SearchNodeRequest) message; new Thread("Search node request") { public void run() { List<MemberInfo> reply = new LinkedList<MemberInfo>(); for (Member m : getController().getNodeManager() .getValidNodes()) { if (m.matches(request.searchString)) { reply.add(m.getInfo()); } } if (!reply.isEmpty()) { sendMessageAsynchron(new KnownNodes(reply .toArray(new MemberInfo[0])), null); } } }.start(); } else { log().warn( "Unknown message received from peer: " + message.getClass().getName()); } // now give the message to all message listeners fireMessageToListeners(message); }
RequestNodeList request = getController().getNodeManager() .createDefaultNodeListRequestMessage();
boolean thisHandshakeCompleted = true;
public boolean completeHandshake() { if (!isConnected()) { return false; } // Create request for nodelist. RequestNodeList request = getController().getNodeManager() .createDefaultNodeListRequestMessage(); synchronized (peerInitalizeLock) { if (!isConnected()) { log().warn("Disconnected while completing handshake"); return false; } // Send node informations now // Send joined folders to synchronize FolderList folderList = new FolderList(getController() .getFolderRepository().getJoinedFolderInfos(), peer .getRemoteMagicId()); peer.sendMessageAsynchron(folderList, null); // Send our transfer status peer.sendMessageAsynchron(getController().getTransferManager() .getStatus(), null); // Send request for nodelist. peer.sendMessageAsynchron(request, null); } // My messages sent, now wait for his folder list. waitForFolderList(); synchronized (peerInitalizeLock) { if (!isConnected()) { log().error("Disconnected while completing handshake"); return false; } if (!isInteresting()) { log().warn("Rejected, Node not interesting"); // Tell remote side try { peer.sendMessage(new Problem("You are boring", true, Problem.YOU_ARE_BORING)); } catch (ConnectionException e) { log().verbose(e); } handshaked = false; } } // Handshaked ? handshaked = isConnected(); if (handshaked) { // Reset things connectionRetries = 0; unableToConnect = false; // if (logEnabled) { log().info( "Connected (" + getController().getNodeManager().countConnectedNodes() + " total)"); // } // Supernode <-> Supernode communication on public networking if (getController().isPublicNetworking() && isSupernode() && getController().getMySelf().isSupernode()) { sendMessageAsynchron(RequestNetworkFolderList.COMPLETE_LIST, "Unable to request network folder list"); } // Inform nodemanger about it getController().getNodeManager().onlineStateChanged(this); if (getController().isVerbose()) { // Running in verbose mode, directly request node information sendMessageAsynchron(new RequestNodeInformation(), null); } } else { // Not handshaked, shutdown shutdown(); } return handshaked; }
peer.sendMessageAsynchron(request, null);
public boolean completeHandshake() { if (!isConnected()) { return false; } // Create request for nodelist. RequestNodeList request = getController().getNodeManager() .createDefaultNodeListRequestMessage(); synchronized (peerInitalizeLock) { if (!isConnected()) { log().warn("Disconnected while completing handshake"); return false; } // Send node informations now // Send joined folders to synchronize FolderList folderList = new FolderList(getController() .getFolderRepository().getJoinedFolderInfos(), peer .getRemoteMagicId()); peer.sendMessageAsynchron(folderList, null); // Send our transfer status peer.sendMessageAsynchron(getController().getTransferManager() .getStatus(), null); // Send request for nodelist. peer.sendMessageAsynchron(request, null); } // My messages sent, now wait for his folder list. waitForFolderList(); synchronized (peerInitalizeLock) { if (!isConnected()) { log().error("Disconnected while completing handshake"); return false; } if (!isInteresting()) { log().warn("Rejected, Node not interesting"); // Tell remote side try { peer.sendMessage(new Problem("You are boring", true, Problem.YOU_ARE_BORING)); } catch (ConnectionException e) { log().verbose(e); } handshaked = false; } } // Handshaked ? handshaked = isConnected(); if (handshaked) { // Reset things connectionRetries = 0; unableToConnect = false; // if (logEnabled) { log().info( "Connected (" + getController().getNodeManager().countConnectedNodes() + " total)"); // } // Supernode <-> Supernode communication on public networking if (getController().isPublicNetworking() && isSupernode() && getController().getMySelf().isSupernode()) { sendMessageAsynchron(RequestNetworkFolderList.COMPLETE_LIST, "Unable to request network folder list"); } // Inform nodemanger about it getController().getNodeManager().onlineStateChanged(this); if (getController().isVerbose()) { // Running in verbose mode, directly request node information sendMessageAsynchron(new RequestNodeInformation(), null); } } else { // Not handshaked, shutdown shutdown(); } return handshaked; }
handshaked = false;
thisHandshakeCompleted = false; } else { peer.sendMessageAsynchron(request, null);
public boolean completeHandshake() { if (!isConnected()) { return false; } // Create request for nodelist. RequestNodeList request = getController().getNodeManager() .createDefaultNodeListRequestMessage(); synchronized (peerInitalizeLock) { if (!isConnected()) { log().warn("Disconnected while completing handshake"); return false; } // Send node informations now // Send joined folders to synchronize FolderList folderList = new FolderList(getController() .getFolderRepository().getJoinedFolderInfos(), peer .getRemoteMagicId()); peer.sendMessageAsynchron(folderList, null); // Send our transfer status peer.sendMessageAsynchron(getController().getTransferManager() .getStatus(), null); // Send request for nodelist. peer.sendMessageAsynchron(request, null); } // My messages sent, now wait for his folder list. waitForFolderList(); synchronized (peerInitalizeLock) { if (!isConnected()) { log().error("Disconnected while completing handshake"); return false; } if (!isInteresting()) { log().warn("Rejected, Node not interesting"); // Tell remote side try { peer.sendMessage(new Problem("You are boring", true, Problem.YOU_ARE_BORING)); } catch (ConnectionException e) { log().verbose(e); } handshaked = false; } } // Handshaked ? handshaked = isConnected(); if (handshaked) { // Reset things connectionRetries = 0; unableToConnect = false; // if (logEnabled) { log().info( "Connected (" + getController().getNodeManager().countConnectedNodes() + " total)"); // } // Supernode <-> Supernode communication on public networking if (getController().isPublicNetworking() && isSupernode() && getController().getMySelf().isSupernode()) { sendMessageAsynchron(RequestNetworkFolderList.COMPLETE_LIST, "Unable to request network folder list"); } // Inform nodemanger about it getController().getNodeManager().onlineStateChanged(this); if (getController().isVerbose()) { // Running in verbose mode, directly request node information sendMessageAsynchron(new RequestNodeInformation(), null); } } else { // Not handshaked, shutdown shutdown(); } return handshaked; }
handshaked = isConnected();
handshaked = thisHandshakeCompleted && isConnected();
public boolean completeHandshake() { if (!isConnected()) { return false; } // Create request for nodelist. RequestNodeList request = getController().getNodeManager() .createDefaultNodeListRequestMessage(); synchronized (peerInitalizeLock) { if (!isConnected()) { log().warn("Disconnected while completing handshake"); return false; } // Send node informations now // Send joined folders to synchronize FolderList folderList = new FolderList(getController() .getFolderRepository().getJoinedFolderInfos(), peer .getRemoteMagicId()); peer.sendMessageAsynchron(folderList, null); // Send our transfer status peer.sendMessageAsynchron(getController().getTransferManager() .getStatus(), null); // Send request for nodelist. peer.sendMessageAsynchron(request, null); } // My messages sent, now wait for his folder list. waitForFolderList(); synchronized (peerInitalizeLock) { if (!isConnected()) { log().error("Disconnected while completing handshake"); return false; } if (!isInteresting()) { log().warn("Rejected, Node not interesting"); // Tell remote side try { peer.sendMessage(new Problem("You are boring", true, Problem.YOU_ARE_BORING)); } catch (ConnectionException e) { log().verbose(e); } handshaked = false; } } // Handshaked ? handshaked = isConnected(); if (handshaked) { // Reset things connectionRetries = 0; unableToConnect = false; // if (logEnabled) { log().info( "Connected (" + getController().getNodeManager().countConnectedNodes() + " total)"); // } // Supernode <-> Supernode communication on public networking if (getController().isPublicNetworking() && isSupernode() && getController().getMySelf().isSupernode()) { sendMessageAsynchron(RequestNetworkFolderList.COMPLETE_LIST, "Unable to request network folder list"); } // Inform nodemanger about it getController().getNodeManager().onlineStateChanged(this); if (getController().isVerbose()) { // Running in verbose mode, directly request node information sendMessageAsynchron(new RequestNodeInformation(), null); } } else { // Not handshaked, shutdown shutdown(); } return handshaked; }
TestHelper.waitMilliSeconds(500);
TestHelper.waitMilliSeconds(10000);
public void testAbortUpload() { assertEquals(0, bartModelListener.events.size()); // Create a 20 megs file TestHelper.createRandomFile(getFolderAtBart().getLocalBase(), 20000000); getFolderAtBart().forceScanOnNextMaintenance(); getFolderAtBart().maintain(); TestHelper.waitForCondition(2, new TestHelper.Condition() { public boolean reached() { return getContollerBart().getTransferManager() .getActiveUploads().length == 1; } }); TestHelper.waitMilliSeconds(100); assertEquals(1, bartModel.getRowCount()); // Upload requested + started assertEquals(2, bartModelListener.events.size()); // Abort Download download = getContollerLisa().getTransferManager() .getActiveDownloads()[0]; download.abort(); TestHelper.waitForCondition(50, new TestHelper.Condition() { public boolean reached() { return bartModel.getRowCount() == 0; } }); // Wait for EDT TestHelper.waitMilliSeconds(500); // no active upload assertEquals(0, bartModel.getRowCount()); // Check correct events from model assertEquals(3, bartModelListener.events.size()); // Upload requested assertTrue(bartModelListener.events.get(0).getType() == TableModelEvent.INSERT); // Upload started assertTrue(bartModelListener.events.get(1).getType() == TableModelEvent.UPDATE); // Upload aborted assertTrue(bartModelListener.events.get(2).getType() == TableModelEvent.DELETE); TestHelper.waitMilliSeconds(500); }
InternalID orderID = new InternalID(""+0);
public Command cancelAllCommand() throws ParserException { consumeToken("Expected cancel all command.", null); InternalID orderID = new InternalID(""+0); Message message = new quickfix.fix42.Message(); message.getHeader().setField(new MsgType(MsgType.ORDER_CANCEL_REQUEST)); List aList = new ArrayList(); aList.add(message); return new Command(MsgType.ORDER_CANCEL_REQUEST, aList); }
return value.equals(matcherValue.toString());
boolean returnValue = shouldInclude ^ value.equals(matcherValue.toString()); return returnValue;
public boolean matches(MessageHolder item) { try { Message aMessage = item.getMessage(); if (matcherValue == null){ try { String value = getFieldValueString(aMessage, matcherFIXField); return (value == null); } catch (FieldNotFound ex){ return true; } } else { String value = getFieldValueString(aMessage, matcherFIXField); return value.equals(matcherValue.toString()); } } catch (Exception ex) { //do nothing } return false; }
TransactTime ttField = new TransactTime(new Date(10000000)); TransactTime ttFieldLater = new TransactTime(new Date(10010000));
SendingTime stField = new SendingTime(new Date(10000000)); SendingTime stFieldLater = new SendingTime(new Date(10010000));
public void testExecutionReportOrder() throws FieldNotFound { InternalID orderID1 = new InternalID("1"); InternalID clOrderID1 = new InternalID("2"); String execID = "3"; char execTransType = ExecTransType.STATUS; char execType = ExecType.PARTIAL_FILL; char ordStatus = OrdStatus.PARTIALLY_FILLED; char side = Side.SELL_SHORT; BigDecimal orderQty = new BigDecimal(1000); BigDecimal orderPrice = new BigDecimal(789); BigDecimal lastQty = new BigDecimal(100); BigDecimal lastPrice = new BigDecimal("12.3"); BigDecimal leavesQty = new BigDecimal(900); BigDecimal cumQty = new BigDecimal(100); BigDecimal avgPrice = new BigDecimal("12.3"); MSymbol symbol = new MSymbol("ASDF"); TransactTime ttField = new TransactTime(new Date(10000000)); TransactTime ttFieldLater = new TransactTime(new Date(10010000)); Message message1 = FIXMessageUtil.newExecutionReport(null, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message1.setField(ttField); lastQty = new BigDecimal(200); Message message2 = FIXMessageUtil.newExecutionReport(orderID1, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message2.setField(ttField); lastQty = new BigDecimal(300); Message message3 = FIXMessageUtil.newExecutionReport(orderID1, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message3.setField(ttFieldLater); FIXMessageHistory history = getMessageHistory(); history.addIncomingMessage(message1); history.addIncomingMessage(message2); assertEquals(new BigDecimal(200), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message2); history.addIncomingMessage(message1); assertEquals(new BigDecimal(100), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertTrue(!history.getLatestExecutionReport(clOrderID1.toString()).isSetField(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message1); history.addIncomingMessage(message2); history.addIncomingMessage(message3); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message3); history.addIncomingMessage(message2); history.addIncomingMessage(message1); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message3); history.addIncomingMessage(message1); history.addIncomingMessage(message2); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD));}
message1.setField(ttField);
message1.getHeader().setField(stField);
public void testExecutionReportOrder() throws FieldNotFound { InternalID orderID1 = new InternalID("1"); InternalID clOrderID1 = new InternalID("2"); String execID = "3"; char execTransType = ExecTransType.STATUS; char execType = ExecType.PARTIAL_FILL; char ordStatus = OrdStatus.PARTIALLY_FILLED; char side = Side.SELL_SHORT; BigDecimal orderQty = new BigDecimal(1000); BigDecimal orderPrice = new BigDecimal(789); BigDecimal lastQty = new BigDecimal(100); BigDecimal lastPrice = new BigDecimal("12.3"); BigDecimal leavesQty = new BigDecimal(900); BigDecimal cumQty = new BigDecimal(100); BigDecimal avgPrice = new BigDecimal("12.3"); MSymbol symbol = new MSymbol("ASDF"); TransactTime ttField = new TransactTime(new Date(10000000)); TransactTime ttFieldLater = new TransactTime(new Date(10010000)); Message message1 = FIXMessageUtil.newExecutionReport(null, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message1.setField(ttField); lastQty = new BigDecimal(200); Message message2 = FIXMessageUtil.newExecutionReport(orderID1, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message2.setField(ttField); lastQty = new BigDecimal(300); Message message3 = FIXMessageUtil.newExecutionReport(orderID1, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message3.setField(ttFieldLater); FIXMessageHistory history = getMessageHistory(); history.addIncomingMessage(message1); history.addIncomingMessage(message2); assertEquals(new BigDecimal(200), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message2); history.addIncomingMessage(message1); assertEquals(new BigDecimal(100), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertTrue(!history.getLatestExecutionReport(clOrderID1.toString()).isSetField(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message1); history.addIncomingMessage(message2); history.addIncomingMessage(message3); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message3); history.addIncomingMessage(message2); history.addIncomingMessage(message1); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message3); history.addIncomingMessage(message1); history.addIncomingMessage(message2); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD));}
message2.setField(ttField);
message2.getHeader().setField(stField);
public void testExecutionReportOrder() throws FieldNotFound { InternalID orderID1 = new InternalID("1"); InternalID clOrderID1 = new InternalID("2"); String execID = "3"; char execTransType = ExecTransType.STATUS; char execType = ExecType.PARTIAL_FILL; char ordStatus = OrdStatus.PARTIALLY_FILLED; char side = Side.SELL_SHORT; BigDecimal orderQty = new BigDecimal(1000); BigDecimal orderPrice = new BigDecimal(789); BigDecimal lastQty = new BigDecimal(100); BigDecimal lastPrice = new BigDecimal("12.3"); BigDecimal leavesQty = new BigDecimal(900); BigDecimal cumQty = new BigDecimal(100); BigDecimal avgPrice = new BigDecimal("12.3"); MSymbol symbol = new MSymbol("ASDF"); TransactTime ttField = new TransactTime(new Date(10000000)); TransactTime ttFieldLater = new TransactTime(new Date(10010000)); Message message1 = FIXMessageUtil.newExecutionReport(null, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message1.setField(ttField); lastQty = new BigDecimal(200); Message message2 = FIXMessageUtil.newExecutionReport(orderID1, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message2.setField(ttField); lastQty = new BigDecimal(300); Message message3 = FIXMessageUtil.newExecutionReport(orderID1, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message3.setField(ttFieldLater); FIXMessageHistory history = getMessageHistory(); history.addIncomingMessage(message1); history.addIncomingMessage(message2); assertEquals(new BigDecimal(200), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message2); history.addIncomingMessage(message1); assertEquals(new BigDecimal(100), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertTrue(!history.getLatestExecutionReport(clOrderID1.toString()).isSetField(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message1); history.addIncomingMessage(message2); history.addIncomingMessage(message3); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message3); history.addIncomingMessage(message2); history.addIncomingMessage(message1); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message3); history.addIncomingMessage(message1); history.addIncomingMessage(message2); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD));}
message3.setField(ttFieldLater);
message3.getHeader().setField(stFieldLater);
public void testExecutionReportOrder() throws FieldNotFound { InternalID orderID1 = new InternalID("1"); InternalID clOrderID1 = new InternalID("2"); String execID = "3"; char execTransType = ExecTransType.STATUS; char execType = ExecType.PARTIAL_FILL; char ordStatus = OrdStatus.PARTIALLY_FILLED; char side = Side.SELL_SHORT; BigDecimal orderQty = new BigDecimal(1000); BigDecimal orderPrice = new BigDecimal(789); BigDecimal lastQty = new BigDecimal(100); BigDecimal lastPrice = new BigDecimal("12.3"); BigDecimal leavesQty = new BigDecimal(900); BigDecimal cumQty = new BigDecimal(100); BigDecimal avgPrice = new BigDecimal("12.3"); MSymbol symbol = new MSymbol("ASDF"); TransactTime ttField = new TransactTime(new Date(10000000)); TransactTime ttFieldLater = new TransactTime(new Date(10010000)); Message message1 = FIXMessageUtil.newExecutionReport(null, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message1.setField(ttField); lastQty = new BigDecimal(200); Message message2 = FIXMessageUtil.newExecutionReport(orderID1, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message2.setField(ttField); lastQty = new BigDecimal(300); Message message3 = FIXMessageUtil.newExecutionReport(orderID1, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message3.setField(ttFieldLater); FIXMessageHistory history = getMessageHistory(); history.addIncomingMessage(message1); history.addIncomingMessage(message2); assertEquals(new BigDecimal(200), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message2); history.addIncomingMessage(message1); assertEquals(new BigDecimal(100), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertTrue(!history.getLatestExecutionReport(clOrderID1.toString()).isSetField(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message1); history.addIncomingMessage(message2); history.addIncomingMessage(message3); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message3); history.addIncomingMessage(message2); history.addIncomingMessage(message1); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message3); history.addIncomingMessage(message1); history.addIncomingMessage(message2); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD));}
assertEquals(new BigDecimal(100), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertTrue(!history.getLatestExecutionReport(clOrderID1.toString()).isSetField(OrderID.FIELD));
assertEquals(new BigDecimal(200), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertTrue(history.getLatestExecutionReport(clOrderID1.toString()).isSetField(OrderID.FIELD));
public void testExecutionReportOrder() throws FieldNotFound { InternalID orderID1 = new InternalID("1"); InternalID clOrderID1 = new InternalID("2"); String execID = "3"; char execTransType = ExecTransType.STATUS; char execType = ExecType.PARTIAL_FILL; char ordStatus = OrdStatus.PARTIALLY_FILLED; char side = Side.SELL_SHORT; BigDecimal orderQty = new BigDecimal(1000); BigDecimal orderPrice = new BigDecimal(789); BigDecimal lastQty = new BigDecimal(100); BigDecimal lastPrice = new BigDecimal("12.3"); BigDecimal leavesQty = new BigDecimal(900); BigDecimal cumQty = new BigDecimal(100); BigDecimal avgPrice = new BigDecimal("12.3"); MSymbol symbol = new MSymbol("ASDF"); TransactTime ttField = new TransactTime(new Date(10000000)); TransactTime ttFieldLater = new TransactTime(new Date(10010000)); Message message1 = FIXMessageUtil.newExecutionReport(null, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message1.setField(ttField); lastQty = new BigDecimal(200); Message message2 = FIXMessageUtil.newExecutionReport(orderID1, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message2.setField(ttField); lastQty = new BigDecimal(300); Message message3 = FIXMessageUtil.newExecutionReport(orderID1, clOrderID1, execID, execTransType, execType, ordStatus, side, orderQty, orderPrice, lastQty, lastPrice, leavesQty, cumQty, avgPrice, symbol, null); message3.setField(ttFieldLater); FIXMessageHistory history = getMessageHistory(); history.addIncomingMessage(message1); history.addIncomingMessage(message2); assertEquals(new BigDecimal(200), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message2); history.addIncomingMessage(message1); assertEquals(new BigDecimal(100), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertTrue(!history.getLatestExecutionReport(clOrderID1.toString()).isSetField(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message1); history.addIncomingMessage(message2); history.addIncomingMessage(message3); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message3); history.addIncomingMessage(message2); history.addIncomingMessage(message1); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD)); history = getMessageHistory(); history.addIncomingMessage(message3); history.addIncomingMessage(message1); history.addIncomingMessage(message2); assertEquals(new BigDecimal(300), new BigDecimal(history.getLatestExecutionReport(clOrderID1.toString()).getString(LastQty.FIELD))); assertEquals(orderID1.toString(), history.getLatestExecutionReport(clOrderID1.toString()).getString(OrderID.FIELD));}
executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 10000)));
executionReportForOrder1.getHeader().setField(new SendingTime(new Date(currentTime - 10000)));
public void testGetLatestExecutionReports() throws FieldNotFound { FIXMessageHistory history = getMessageHistory(); Message order1 = FIXMessageUtil.newMarketOrder(new InternalID("1"), Side.BUY, new BigDecimal(1000), new MSymbol("ASDF"), TimeInForce.FILL_OR_KILL, new AccountID("ACCT")); Message executionReportForOrder1 = FIXMessageUtil.newExecutionReport(new InternalID("1001"), new InternalID("1"), "2001", ExecTransType.NEW, ExecType.NEW, OrdStatus.NEW, Side.BUY, new BigDecimal(1000), new BigDecimal(789), null, null, new BigDecimal(1000), BigDecimal.ZERO, BigDecimal.ZERO, new MSymbol("ASDF"), null); executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 10000))); Message order2 = FIXMessageUtil.newLimitOrder(new InternalID("3"), Side.SELL, new BigDecimal(2000), new MSymbol("QWER"), new BigDecimal("12.3"), TimeInForce.DAY, new AccountID("ACCT")); Message executionReportForOrder2 = FIXMessageUtil.newExecutionReport(new InternalID("1003"), new InternalID("3"), "2003", ExecTransType.NEW, ExecType.NEW, OrdStatus.NEW, Side.SELL, new BigDecimal(2000), new BigDecimal(789), null, null, new BigDecimal(2000), BigDecimal.ZERO, BigDecimal.ZERO, new MSymbol("QWER"), null); executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 8000))); Message secondExecutionReportForOrder1 = FIXMessageUtil.newExecutionReport(new InternalID("1001"), new InternalID("1"), "2004", ExecTransType.STATUS, ExecType.PARTIAL_FILL, OrdStatus.PARTIALLY_FILLED, Side.BUY, new BigDecimal(1000), new BigDecimal(789), new BigDecimal(100), new BigDecimal("11.5"), new BigDecimal(900), new BigDecimal(100), new BigDecimal("11.5"), new MSymbol("ASDF"), null); executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 7000))); history.addOutgoingMessage(order1); history.addIncomingMessage(executionReportForOrder1); history.addOutgoingMessage(order2); history.addIncomingMessage(executionReportForOrder2); history.addIncomingMessage(secondExecutionReportForOrder1); EventList<MessageHolder> historyList = history.getLatestExecutionReports(); assertEquals(2, historyList.size()); Message historyExecutionReportForOrder1 = historyList.get(0).getMessage(); Message historyExecutionReportForOrder2 = historyList.get(1).getMessage(); assertEquals("1001", historyExecutionReportForOrder1.getString(OrderID.FIELD)); assertEquals("2004", historyExecutionReportForOrder1.getString(ExecID.FIELD)); assertEquals(order1.getString(ClOrdID.FIELD), historyExecutionReportForOrder1.getString(ClOrdID.FIELD)); assertEquals(order1.getString(Side.FIELD), historyExecutionReportForOrder1.getString(Side.FIELD)); assertEquals(order1.getString(OrderQty.FIELD), historyExecutionReportForOrder1.getString(OrderQty.FIELD)); assertEquals(order1.getString(Symbol.FIELD), historyExecutionReportForOrder1.getString(Symbol.FIELD)); assertEquals("1003", historyExecutionReportForOrder2.getString(OrderID.FIELD)); assertEquals("2003", historyExecutionReportForOrder2.getString(ExecID.FIELD)); assertEquals(order2.getString(ClOrdID.FIELD), historyExecutionReportForOrder2.getString(ClOrdID.FIELD)); assertEquals(order2.getString(Side.FIELD), historyExecutionReportForOrder2.getString(Side.FIELD)); assertEquals(order2.getString(OrderQty.FIELD), historyExecutionReportForOrder2.getString(OrderQty.FIELD)); assertEquals(order2.getString(Symbol.FIELD), historyExecutionReportForOrder2.getString(Symbol.FIELD));}
executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 8000)));
executionReportForOrder2.getHeader().setField(new SendingTime(new Date(currentTime - 8000)));
public void testGetLatestExecutionReports() throws FieldNotFound { FIXMessageHistory history = getMessageHistory(); Message order1 = FIXMessageUtil.newMarketOrder(new InternalID("1"), Side.BUY, new BigDecimal(1000), new MSymbol("ASDF"), TimeInForce.FILL_OR_KILL, new AccountID("ACCT")); Message executionReportForOrder1 = FIXMessageUtil.newExecutionReport(new InternalID("1001"), new InternalID("1"), "2001", ExecTransType.NEW, ExecType.NEW, OrdStatus.NEW, Side.BUY, new BigDecimal(1000), new BigDecimal(789), null, null, new BigDecimal(1000), BigDecimal.ZERO, BigDecimal.ZERO, new MSymbol("ASDF"), null); executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 10000))); Message order2 = FIXMessageUtil.newLimitOrder(new InternalID("3"), Side.SELL, new BigDecimal(2000), new MSymbol("QWER"), new BigDecimal("12.3"), TimeInForce.DAY, new AccountID("ACCT")); Message executionReportForOrder2 = FIXMessageUtil.newExecutionReport(new InternalID("1003"), new InternalID("3"), "2003", ExecTransType.NEW, ExecType.NEW, OrdStatus.NEW, Side.SELL, new BigDecimal(2000), new BigDecimal(789), null, null, new BigDecimal(2000), BigDecimal.ZERO, BigDecimal.ZERO, new MSymbol("QWER"), null); executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 8000))); Message secondExecutionReportForOrder1 = FIXMessageUtil.newExecutionReport(new InternalID("1001"), new InternalID("1"), "2004", ExecTransType.STATUS, ExecType.PARTIAL_FILL, OrdStatus.PARTIALLY_FILLED, Side.BUY, new BigDecimal(1000), new BigDecimal(789), new BigDecimal(100), new BigDecimal("11.5"), new BigDecimal(900), new BigDecimal(100), new BigDecimal("11.5"), new MSymbol("ASDF"), null); executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 7000))); history.addOutgoingMessage(order1); history.addIncomingMessage(executionReportForOrder1); history.addOutgoingMessage(order2); history.addIncomingMessage(executionReportForOrder2); history.addIncomingMessage(secondExecutionReportForOrder1); EventList<MessageHolder> historyList = history.getLatestExecutionReports(); assertEquals(2, historyList.size()); Message historyExecutionReportForOrder1 = historyList.get(0).getMessage(); Message historyExecutionReportForOrder2 = historyList.get(1).getMessage(); assertEquals("1001", historyExecutionReportForOrder1.getString(OrderID.FIELD)); assertEquals("2004", historyExecutionReportForOrder1.getString(ExecID.FIELD)); assertEquals(order1.getString(ClOrdID.FIELD), historyExecutionReportForOrder1.getString(ClOrdID.FIELD)); assertEquals(order1.getString(Side.FIELD), historyExecutionReportForOrder1.getString(Side.FIELD)); assertEquals(order1.getString(OrderQty.FIELD), historyExecutionReportForOrder1.getString(OrderQty.FIELD)); assertEquals(order1.getString(Symbol.FIELD), historyExecutionReportForOrder1.getString(Symbol.FIELD)); assertEquals("1003", historyExecutionReportForOrder2.getString(OrderID.FIELD)); assertEquals("2003", historyExecutionReportForOrder2.getString(ExecID.FIELD)); assertEquals(order2.getString(ClOrdID.FIELD), historyExecutionReportForOrder2.getString(ClOrdID.FIELD)); assertEquals(order2.getString(Side.FIELD), historyExecutionReportForOrder2.getString(Side.FIELD)); assertEquals(order2.getString(OrderQty.FIELD), historyExecutionReportForOrder2.getString(OrderQty.FIELD)); assertEquals(order2.getString(Symbol.FIELD), historyExecutionReportForOrder2.getString(Symbol.FIELD));}
executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 7000)));
secondExecutionReportForOrder1.getHeader().setField(new SendingTime(new Date(currentTime - 7000)));
public void testGetLatestExecutionReports() throws FieldNotFound { FIXMessageHistory history = getMessageHistory(); Message order1 = FIXMessageUtil.newMarketOrder(new InternalID("1"), Side.BUY, new BigDecimal(1000), new MSymbol("ASDF"), TimeInForce.FILL_OR_KILL, new AccountID("ACCT")); Message executionReportForOrder1 = FIXMessageUtil.newExecutionReport(new InternalID("1001"), new InternalID("1"), "2001", ExecTransType.NEW, ExecType.NEW, OrdStatus.NEW, Side.BUY, new BigDecimal(1000), new BigDecimal(789), null, null, new BigDecimal(1000), BigDecimal.ZERO, BigDecimal.ZERO, new MSymbol("ASDF"), null); executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 10000))); Message order2 = FIXMessageUtil.newLimitOrder(new InternalID("3"), Side.SELL, new BigDecimal(2000), new MSymbol("QWER"), new BigDecimal("12.3"), TimeInForce.DAY, new AccountID("ACCT")); Message executionReportForOrder2 = FIXMessageUtil.newExecutionReport(new InternalID("1003"), new InternalID("3"), "2003", ExecTransType.NEW, ExecType.NEW, OrdStatus.NEW, Side.SELL, new BigDecimal(2000), new BigDecimal(789), null, null, new BigDecimal(2000), BigDecimal.ZERO, BigDecimal.ZERO, new MSymbol("QWER"), null); executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 8000))); Message secondExecutionReportForOrder1 = FIXMessageUtil.newExecutionReport(new InternalID("1001"), new InternalID("1"), "2004", ExecTransType.STATUS, ExecType.PARTIAL_FILL, OrdStatus.PARTIALLY_FILLED, Side.BUY, new BigDecimal(1000), new BigDecimal(789), new BigDecimal(100), new BigDecimal("11.5"), new BigDecimal(900), new BigDecimal(100), new BigDecimal("11.5"), new MSymbol("ASDF"), null); executionReportForOrder1.setField(new TransactTime(new Date(System.currentTimeMillis() - 7000))); history.addOutgoingMessage(order1); history.addIncomingMessage(executionReportForOrder1); history.addOutgoingMessage(order2); history.addIncomingMessage(executionReportForOrder2); history.addIncomingMessage(secondExecutionReportForOrder1); EventList<MessageHolder> historyList = history.getLatestExecutionReports(); assertEquals(2, historyList.size()); Message historyExecutionReportForOrder1 = historyList.get(0).getMessage(); Message historyExecutionReportForOrder2 = historyList.get(1).getMessage(); assertEquals("1001", historyExecutionReportForOrder1.getString(OrderID.FIELD)); assertEquals("2004", historyExecutionReportForOrder1.getString(ExecID.FIELD)); assertEquals(order1.getString(ClOrdID.FIELD), historyExecutionReportForOrder1.getString(ClOrdID.FIELD)); assertEquals(order1.getString(Side.FIELD), historyExecutionReportForOrder1.getString(Side.FIELD)); assertEquals(order1.getString(OrderQty.FIELD), historyExecutionReportForOrder1.getString(OrderQty.FIELD)); assertEquals(order1.getString(Symbol.FIELD), historyExecutionReportForOrder1.getString(Symbol.FIELD)); assertEquals("1003", historyExecutionReportForOrder2.getString(OrderID.FIELD)); assertEquals("2003", historyExecutionReportForOrder2.getString(ExecID.FIELD)); assertEquals(order2.getString(ClOrdID.FIELD), historyExecutionReportForOrder2.getString(ClOrdID.FIELD)); assertEquals(order2.getString(Side.FIELD), historyExecutionReportForOrder2.getString(Side.FIELD)); assertEquals(order2.getString(OrderQty.FIELD), historyExecutionReportForOrder2.getString(OrderQty.FIELD)); assertEquals(order2.getString(Symbol.FIELD), historyExecutionReportForOrder2.getString(Symbol.FIELD));}
folder1.setSyncProfile(SyncProfile.SYNCHRONIZE_PCS); folder2.setSyncProfile(SyncProfile.MANUAL_DOWNLOAD); RecycleBin recycleBin = getContoller2().getRecycleBin(); List<FileInfo> deletedFiles = getContoller2().getRecycleBin() .getAllRecycledFiles(); for (FileInfo deletedFileInfo : deletedFiles) { recycleBin.restoreFromRecycleBin(deletedFileInfo); } for (FileInfo fileInfo : folder2.getFiles()) { assertEquals(0, fileInfo.getVersion()); } Thread.sleep(3000); assertEquals(folder1.getFilesCount(), 3); for (FileInfo fileInfo : folder1.getFiles()) { assertEquals(0, fileInfo.getVersion()); }
public void testDeletionSync() throws IOException, InterruptedException { // file "host" and "client" folder1.setSyncProfile(SyncProfile.MANUAL_DOWNLOAD); folder2.setSyncProfile(SyncProfile.SYNCHRONIZE_PCS); File file1 = createTestFile(folder1, "/TestFile.txt", "This are the contents of the testfile".getBytes()); File file2 = createTestFile(folder1, "/TestFile2.txt", "This are the contents of the 2nd testfile".getBytes()); File file3 = createTestFile(folder1, "/sub/sub/TestFile3.txt", "This are the contents of the 3nd testfile".getBytes()); // Let him scan the new content folder1.forceNextScan(); folder1.scan(); assertEquals(3, folder1.getFilesCount()); // Give them time to copy Thread.sleep(3000); // Test ;) assertEquals(3, folder2.getFilesCount()); // No active downloads? assertEquals(0, getContoller2().getTransferManager() .getActiveDownloadCount()); assertEquals(getContoller1().getRecycleBin().getSize(), 0); assertEquals(getContoller2().getRecycleBin().getSize(), 0); file1.delete(); file2.delete(); file3.delete(); assertFalse(file1.exists()); assertFalse(file2.exists()); assertFalse(file3.exists()); // Let him scan the new content folder1.forceNextScan(); folder1.scan(); //all 3 must be deleted FileInfo[] localFiles = folder1.getFiles(); for (FileInfo fileInfo : localFiles) { assertTrue(fileInfo.isDeleted()); } // Give them time to copy Thread.sleep(3000); // all 3 must be deleted remote FileInfo[] remoteFiles = folder2.getFiles(); for (FileInfo fileInfo : remoteFiles) { assertTrue(fileInfo.isDeleted()); File file = folder2.getDiskFile(fileInfo); assertFalse(file.exists()); } assertEquals(getContoller2().getRecycleBin().getSize(), 3); }
LoggerAdapter.error("Could not find exchange for " + marketIdentifierCode, this);
LoggerAdapter.error(MessageKey.ERROR_EXCHANGE_DNE.getLocalizedMessage(marketIdentifierCode), this);
private void init(Properties props) { Map<String, Exchange> map = new HashMap<String, Exchange>(); for (Object o : props.keySet()) { String key = (String) o; String marketIdentifierCode = (String) props.get(key); Exchange exch = Exchanges.getExchange(marketIdentifierCode); if (exch == null) { LoggerAdapter.error("Could not find exchange for " + marketIdentifierCode, this); } else { map.put(key, exch); } } init(map); }
boolean timeout = TestHelper.waitForCondition(200, new Condition() {
boolean succes = TestHelper.waitForCondition(200, new Condition() {
private void scanFolder() { scanned = false; getFolder().forceScanOnNextMaintenance(); getController().getFolderRepository().triggerMaintenance(); boolean timeout = TestHelper.waitForCondition(200, new Condition() { public boolean reached() { return scanned; } }); assertFalse("Folder was not scanned as requested", timeout); assertTrue("Folder was not scanned as requested", scanned); }
assertFalse("Folder was not scanned as requested", timeout);
assertTrue("Folder was not scanned as requested", succes);
private void scanFolder() { scanned = false; getFolder().forceScanOnNextMaintenance(); getController().getFolderRepository().triggerMaintenance(); boolean timeout = TestHelper.waitForCondition(200, new Condition() { public boolean reached() { return scanned; } }); assertFalse("Folder was not scanned as requested", timeout); assertTrue("Folder was not scanned as requested", scanned); }
WaveletConfigServer.debugPrint("Payload: ");
CompassTools.debugPrint("Payload: ");
private void debugMsg(Message msg) { WaveletConfigServer.debugPrint("Payload: "); for (int i = 0; i < msg.dataLength(); i++) { WaveletConfigServer.debugPrint(Integer.toHexString(msg.dataGet()[i] & 0xff) + " "); } WaveletConfigServer.debugPrintln(); }
WaveletConfigServer.debugPrint(Integer.toHexString(msg.dataGet()[i] & 0xff)
CompassTools.debugPrint(Integer.toHexString(msg.dataGet()[i] & 0xff)
private void debugMsg(Message msg) { WaveletConfigServer.debugPrint("Payload: "); for (int i = 0; i < msg.dataLength(); i++) { WaveletConfigServer.debugPrint(Integer.toHexString(msg.dataGet()[i] & 0xff) + " "); } WaveletConfigServer.debugPrintln(); }
WaveletConfigServer.debugPrintln();
CompassTools.debugPrintln();
private void debugMsg(Message msg) { WaveletConfigServer.debugPrint("Payload: "); for (int i = 0; i < msg.dataLength(); i++) { WaveletConfigServer.debugPrint(Integer.toHexString(msg.dataGet()[i] & 0xff) + " "); } WaveletConfigServer.debugPrintln(); }
FilenameProblemDialog dialog = new FilenameProblemDialog( getController(), true, fileNameProblemEvent.getScanResult()); dialog.open();
final FilenameProblemDialog dialog = new FilenameProblemDialog( getController(), fileNameProblemEvent.getScanResult()); Runnable runner = new Runnable() { public void run() { dialog.open(); } }; UIUtil.invokeLaterInEDT(runner);
public void fileNameProblemsDetected( FileNameProblemEvent fileNameProblemEvent) { log().debug( "****************** " + fileNameProblemEvent.getFolder() + " " + fileNameProblemEvent.getScanResult().getProblemFiles()); FilenameProblemDialog dialog = new FilenameProblemDialog( getController(), true, fileNameProblemEvent.getScanResult()); dialog.open(); }
.getTranslation("foldercreate.error.unable_tocreate",
.getTranslation("foldercreate.error.unable_to_create",
private void checkBaseDir(File baseDir) throws FolderException { // Basic checks if (!localBase.exists()) { if (!localBase.mkdirs()) { throw new FolderException(getInfo(), Translation .getTranslation("foldercreate.error.unable_tocreate", localBase.getAbsolutePath())); } } else if (!localBase.isDirectory()) { throw new FolderException(getInfo(), Translation.getTranslation( "foldercreate.error.unable_to_open", localBase .getAbsolutePath())); } // Complex checks FolderRepository repo = getController().getFolderRepository(); if (new File(repo.getFoldersBasedir()).equals(baseDir)) { throw new FolderException(getInfo(), Translation.getTranslation( "foldercreate.error.it_is_base_dir", baseDir.getAbsolutePath())); } // FIXME This one does not happen here (Jan) // I can choose a base dir that allready has a powerfolder in it FolderInfo[] folderInfos = repo.getJoinedFolderInfos(); for (FolderInfo folderInfo : folderInfos) { Folder folder = repo.getFolder(folderInfo); if (folder != null) { if (folder.getLocalBase().equals(baseDir)) { throw new FolderException(getInfo(), Translation .getTranslation("foldercreate.error.already_taken", folder.getName(), baseDir.getAbsolutePath())); } } } }
mPreferences = new ScopedPreferenceStore(new ConfigurationScope(), Application.PLUGIN_ID); setPreferenceStore(mPreferences);
preferences = new ScopedPreferenceStore(new ConfigurationScope(), Application.PLUGIN_ID); setPreferenceStore(preferences);
public JMSPreferencePage() { super(GRID); mPreferences = new ScopedPreferenceStore(new ConfigurationScope(), Application.PLUGIN_ID); setPreferenceStore(mPreferences); }