dataDir, mysqldVersion, guessArch); if (mysqld.isRunning()) { int runningPort = mysqld.getPort(); if (port != runningPort) { String location = mysqld.getBaseDir().getPath(); if (dataDir != null) { location += " with data at " + dataDir; mysqld.start(threadName, serverOpts);
public void testAutoStart() throws Exception { MysqldResourceI mysqld = new MysqldResourceTestImpl(); MysqldDynamicMBean myBean = new MysqldDynamicMBean(mysqld); assertFalse(mysqld.isRunning()); String autostart = SimpleMysqldDynamicMBean.AUTOSTART_ATTR; String str_true = Boolean.TRUE.toString(); myBean.setAttribute(new Attribute(autostart, str_true)); assertTrue(mysqld.isRunning()); assertFalse(mysqld.getServerOptions().containsKey(autostart)); } }
protected void tearDown() { super.tearDown(); if (conn != null) { try { conn.close(); } catch (Exception e) { e.printStackTrace(); } conn = null; } if (mysqld != null) { try { mysqld.setKillDelay(testUtil.testKillDelay()); mysqld.shutdown(); } catch (Exception e) { e.printStackTrace(); } } }
private void ensureMysqlStarted(final String mapKey, int port, Properties props) { if (getStartedMysqlds().containsKey(mapKey)) { return; } Map serverOpts = new HashMap(); for (Enumeration enums = props.propertyNames(); enums.hasMoreElements();) { String key = enums.nextElement().toString(); if (key.startsWith(SERVER_DOT)) { serverOpts.put(key.substring(SERVER_DOT.length()), props .getProperty(key)); } } serverOpts.put(MysqldResourceI.PORT, Integer.toString(port)); File baseDir = new FileUtil().newFile(serverOpts .get(MysqldResourceI.BASEDIR)); MysqldResourceI mysqld = resourceFactory.newMysqldResource(baseDir); mysqld.addCompletionListenser(new Runnable() { public void run() { remove(mapKey); } }); launchCount++; String threadName = "driver_launched_mysqld_" + launchCount; mysqld.start(threadName, serverOpts); getStartedMysqlds().put(mapKey, mysqld); }
fileUtil.deleteTree(baseDir4); mysqld = new MysqldResource(baseDir4); mysqld.setKillDelay(testUtil.testKillDelay()); String alicePass = "q3htgi98q34"; mysqld.start("init-user", params); mysqld.setKillDelay(testUtil.testKillDelay()); mysqld.shutdown(); assertEquals(false, mysqld.isRunning()); fileUtil.deleteTree(baseDir4); params.put(MysqldResourceI.INITIALIZE_USER_NAME, aliceName); params.put(MysqldResourceI.INITIALIZE_PASSWORD, alicePass); mysqld.start("init-user", params); mysqld.setKillDelay(testUtil.testKillDelay()); mysqld.shutdown();
bean.getMysqldResource().setKillDelay(testUtil.testKillDelay()); agent.addBean("mysql", "MySQL1", bean); assertEquals(false, bean.getMysqldResource().isRunning()); String port = "" + testUtil.testPort(); assertEquals("3306", bean.getMysqldResource().getServerOptions().get( MysqldResourceI.PORT)); int i = 0; while (++i < 100) { if (bean.getMysqldResource().isRunning()) { break; .isRunning()); assertEquals(port, "" + bean.getMysqldResource().getPort()); assertEquals(port, bean.getMysqldResource().getServerOptions().get( MysqldResourceI.PORT)); assertEquals(dataDir, bean.getMysqldResource().getDataDir());
if (mysqldResource == null || !mysqldResource.isRunning()) { newMysqldResource(); mysqldResource.start("MysqldMBean", attributesToOpionMap(), true); getMBeanOperationInfoList().remove(startMysqldOp); getMBeanOperationInfoList().add(stopOp); newMysqldResource(); mysqldResource.shutdown(); getMBeanOperationInfoList().remove(stopOp); getMBeanOperationInfoList().add(startMysqldOp);
public void testAutoStart() throws Exception { MysqldResourceI mysqld = new MysqldResourceTestImpl(); JBossMysqldDynamicMBean myBean = new JBossMysqldDynamicMBean(mysqld); assertFalse(mysqld.isRunning()); String autostart = SimpleMysqldDynamicMBean.AUTOSTART_ATTR; String str_true = Boolean.TRUE.toString(); myBean.setAttribute(new Attribute(autostart, str_true)); assertFalse(mysqld.isRunning()); myBean.create(); assertTrue(mysqld.isRunning()); }
public void testEverything() throws Exception { agent = new MysqldDynamicMBeanTestAgent("mysql"); String url = "jdbc:mysql:///test" + "?" + NonRegisteringDriver.PROPERTIES_TRANSFORM_KEY + "=" + ConnectorMXJPropertiesTransform.class.getName(); bean = new MysqldDynamicMBean(); bean.getMysqldResource().setKillDelay(testUtil.testKillDelay()); agent.addBean("mysql", "MySQL1", bean); assertEquals(false, bean.getMysqldResource().isRunning()); String port = "" + testUtil.testPort(); assertEquals("3306", bean.getMysqldResource().getServerOptions().get( MysqldResourceI.PORT)); bean.setAttribute(new Attribute(MysqldResourceI.PORT, port)); bean.invoke(SimpleMysqldDynamicMBean.START_METHOD, null, null); int i = 0; while (++i < 100) { if (bean.getMysqldResource().isRunning()) { break; } threads.pause(50); } assertTrue("still not started: " + i, bean.getMysqldResource() .isRunning()); assertEquals(port, bean.getMysqldResource().getServerOptions().get( MysqldResourceI.PORT)); new TestUtil().assertConnectViaJDBC(url); }
.testKillDelay())); mysqld.start("mxj-user-test", params); String rootPassword = ""; makeDb(url + "test", rootUser, rootPassword); checkVersion(mysqld.getVersion()); checkVersion(mysqld.getVersion());
/** * Allows the JMX Agent to pass along calls of "startMysqld" or * "startMysqld" with no args of any type */ public synchronized Object invoke(String methodName, Object args[], String types[]) throws ReflectionException { lastInvocation = new Object[] { methodName, args, types }; clearMBeanInfo(); if (methodName.equals(START_METHOD)) { mysqldResource.start("MysqldMBean", attributesToOpionMap()); getMBeanOperationInfoList().remove(startMysqldOp); getMBeanOperationInfoList().add(stopOp); freezeAttributes(); return null; } if (methodName.equals(STOP_METHOD)) { mysqldResource.shutdown(); getMBeanOperationInfoList().remove(stopOp); getMBeanOperationInfoList().add(startMysqldOp); initAttributes(); return null; } String msg = methodName + " not implemented"; throw new ReflectionException(new NoSuchMethodException(msg), msg); }
Map serverParams = mysqldResource.getServerOptions(); assertEquals("wiz", serverParams.get("baz")); assertFalse("wiz", serverParams.containsKey("foo")); mysqld.shutdown();
private void initAttributes() { attributes = new DefaultsMap(); Map options = new TreeMap(mysqldResource.getServerOptions()); List attInfs = new ArrayList(); makeAttribute(attInfs, AUTOSTART_ATTR, Boolean.FALSE.toString(), true); for (Iterator iter = options.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String attName = (String) entry.getKey(); String attValue = (String) entry.getValue(); makeAttribute(attInfs, attName, attValue, true); } makeAttribute(attInfs, versionAttributeName(), VERSION, false); this.attrInfos = (MBeanAttributeInfo[]) attInfs .toArray(new MBeanAttributeInfo[attInfs.size()]); }
public static void shutdown(String hostColonPort, PrintStream out) { synchronized (startedMysqlds) { Object obj = startedMysqlds.get(hostColonPort); MysqldResourceI mysqld = (MysqldResourceI) obj; if (mysqld != null) { startedMysqlds.remove(hostColonPort); mysqld.shutdown(); } else { String list = new Str().toString(startedMysqlds.keySet()); out.println("mysqld [" + hostColonPort + "] not found in " + list); } } } }
public void testCreateAndDestroy() throws Exception { Map atts = new HashMap(); atts.put(SimpleMysqldDynamicMBean.AUTOSTART_ATTR, Boolean.TRUE .toString()); MysqldResourceI mysqld = new MysqldResourceTestImpl(atts); JBossMysqldDynamicMBean myBean = new JBossMysqldDynamicMBean(mysqld); assertFalse(mysqld.isRunning()); myBean.invoke(JBossMysqldDynamicMBean.CREATE_METHOD, null, null); assertTrue(mysqld.isRunning()); myBean.invoke(JBossMysqldDynamicMBean.DESTROY_METHOD, null, null); assertFalse(mysqld.isRunning()); } }
params.put(MysqldResourceI.PORT, Integer.toString(port)); mysqld.start("mxj-user-test", params); String rootPassword = ""; makeDb(url + "test", rootUser, rootPassword); checkVersion(mysqld.getVersion()); checkVersion(mysqld.getVersion());
Map serverParams = mysqldResource.getServerOptions(); assertEquals("wiz", serverParams.get("baz")); assertFalse("wiz", serverParams.containsKey("foo")); mysqldResource.shutdown();
private void initAttributes() { attributes = new DefaultsMap(); Map options = new TreeMap(mysqldFactory.newMysqldResource(null, null, null).getServerOptions()); List attInfs = new ArrayList(); makeAttribute(attInfs, AUTOSTART_ATTR, Boolean.FALSE.toString(), true); for (Iterator iter = options.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String attName = (String) entry.getKey(); String attValue = (String) entry.getValue(); makeAttribute(attInfs, attName, attValue, true); } makeAttribute(attInfs, versionAttributeName(), VERSION, false); this.attrInfos = (MBeanAttributeInfo[]) attInfs .toArray(new MBeanAttributeInfo[attInfs.size()]); }
mysqld.shutdown(); } catch (Exception e) { e.printStackTrace();
dataDir, mysqldVersion); if (mysqld.isRunning()) { int runningPort = mysqld.getPort(); if (port != runningPort) { runningPort = mysqld.getPort(); String location = mysqld.getBaseDir().getPath(); if (dataDir != null) { location += " with data at " + dataDir; mysqld.start(threadName, serverOpts);