List of usage examples for java.lang Thread yield
public static native void yield();
From source file:org.apache.hadoop.mapreduce.v2.app.speculate.DefaultSpeculator.java
public void scanForSpeculations() { LOG.info("We got asked to run a debug speculation scan."); // debug/* w w w .j a v a 2 s . co m*/ System.out.println("We got asked to run a debug speculation scan."); System.out.println("There are " + scanControl.size() + " events stacked already."); scanControl.add(new Object()); Thread.yield(); }
From source file:org.apache.hadoop.hbase.stargate.TestRowResource.java
void doTestSingleCellGetJSON() throws IOException, JAXBException { final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1; Response response = client.put(path, MIMETYPE_BINARY, Bytes.toBytes(VALUE_4)); assertEquals(response.getCode(), 200); Thread.yield(); response = client.get(path, MIMETYPE_JSON); assertEquals(response.getCode(), 200); response = deleteRow(TABLE, ROW_4);/*w ww . j ava 2 s .com*/ assertEquals(response.getCode(), 200); }
From source file:org.apache.hadoop.hbase.rest.TestGetAndPutResource.java
@Test public void testSingleCellGetPutBinary() throws IOException { final String path = "/" + TABLE + "/" + ROW_3 + "/" + COLUMN_1; final byte[] body = Bytes.toBytes(VALUE_3); Response response = client.put(path, Constants.MIMETYPE_BINARY, body); assertEquals(response.getCode(), 200); Thread.yield();//from w ww. ja v a 2 s. com response = client.get(path, Constants.MIMETYPE_BINARY); assertEquals(response.getCode(), 200); assertEquals(Constants.MIMETYPE_BINARY, response.getHeader("content-type")); assertTrue(Bytes.equals(response.getBody(), body)); boolean foundTimestampHeader = false; for (Header header : response.getHeaders()) { if (header.getName().equals("X-Timestamp")) { foundTimestampHeader = true; break; } } assertTrue(foundTimestampHeader); response = deleteRow(TABLE, ROW_3); assertEquals(response.getCode(), 200); }
From source file:org.apache.hadoop.hbase.rest.TestRowResource.java
private static Response checkAndPutValueXML(String url, String table, String row, String column, String valueToCheck, String valueToPut) throws IOException, JAXBException { RowModel rowModel = new RowModel(row); rowModel.addCell(new CellModel(Bytes.toBytes(column), Bytes.toBytes(valueToPut))); rowModel.addCell(new CellModel(Bytes.toBytes(column), Bytes.toBytes(valueToCheck))); CellSetModel cellSetModel = new CellSetModel(); cellSetModel.addRow(rowModel);/*from w w w .j a v a 2 s . com*/ StringWriter writer = new StringWriter(); marshaller.marshal(cellSetModel, writer); Response response = client.put(url, Constants.MIMETYPE_XML, Bytes.toBytes(writer.toString())); Thread.yield(); return response; }
From source file:org.mule.providers.ldap.MuleEmbeddedTestCase.java
public synchronized void testDispatchReceiveSearchDeleted() throws Exception { MuleClient client = new MuleClient(); final int addCount = 4; LDAPAddRequest last = null;/*from ww w . java2 s.c o m*/ for (int i = 0; i < addCount; i++) { client.dispatch("ldap://ldap.out", last = TestHelper.getRandomEntryAddRequest(), null); } Thread.yield(); Thread.sleep(10000); client.dispatch("ldap://ldap.out", new LDAPDeleteRequest(last.getEntry().getDN(), null), null); Thread.yield(); Thread.sleep(10000); // we send a message on the endpoint we created, i.e. vm://Single client.dispatch("ldap://ldap.out/cn.payload", last.getEntry().getDN(), null); Thread.yield(); Thread.sleep(10000); UMOMessage result = null; UMOMessage lastResult = null; int count = 0; // addCount AddResponses, 1x Search Result, 1 delete response final int expected = addCount + 1 + 1; while (true) { result = client.receive("ldap://ldap.in", 15000); if (result == null) { break; } logger.debug(LDAPUtils.dumpLDAPMessage(result.getPayload())); lastResult = result; count++; } assertTrue("Count (" + count + ") != expected (" + expected + ")", count == expected); // fails because of list returnded or // processing time to short? assertNull(result); assertNotNull(lastResult); assertTrue("instanceof " + lastResult.getPayload().getClass() + " instead of LDAPResponse", lastResult.getPayload() instanceof LDAPResponse); // TODO order is not predictable // assertTrue( // "Check type: " // + ((LDAPResponse) lastResult.getPayload()).getType() // + " should be " + LDAPMessage.SEARCH_RESULT, // ((LDAPResponse) lastResult.getPayload()).getType() == // LDAPMessage.SEARCH_RESULT); // is 2xaddresponse, 1 searchresult, 1 addresponse, 1 delresponse, 1 // addresponse }
From source file:org.apache.synapse.transport.mail.MailEchoRawXMLTest.java
public void testRoundTripPOPDefaultCharsetSOAP12() throws Exception { String msgId = UUIDGenerator.getUUID(); Options options = new Options(); options.setTo(new EndpointReference("mailto:synapse.test.6@gmail.com")); options.setReplyTo(new EndpointReference("mailto:synapse.test.0@gmail.com")); options.setAction(Constants.AXIS2_NAMESPACE_URI + "/echoOMElement"); options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); options.setMessageId(msgId);//from ww w . ja v a 2s . c om ServiceClient sender = new ServiceClient(getClientCfgCtx(), null); sender.setOptions(options); sender.fireAndForget(createPayload()); Thread.yield(); Thread.sleep(1000 * 10); Object reply = null; boolean replyNotFound = true; int retryCount = 3; while (replyNotFound) { log.debug("Checking for response ... with MessageID : " + msgId); reply = getMessage(msgId); if (reply != null) { replyNotFound = false; } else { if (retryCount-- > 0) { Thread.sleep(10000); } else { break; } } } if (reply != null && reply instanceof String) { log.debug("Result Body : " + reply); XMLStreamReader reader = StAXUtils.createXMLStreamReader(new StringReader((String) reply)); SOAPEnvelope env = new StAXSOAPModelBuilder(reader).getSOAPEnvelope(); if (env != null) { AXIOMXPath xpath = new AXIOMXPath("//my:myValue"); xpath.addNamespace("my", "http://localhost/axis2/services/EchoXMLService"); Object result = xpath.evaluate(env); if (result != null && result instanceof OMElement) { assertEquals("omTextValue", ((OMElement) result).getText()); } } } else { fail("Did not receive the reply mail"); } }
From source file:org.newdawn.ardor3d.loader.max.MaxModelViewer.java
public void start() throws URISyntaxException, IOException { DisplaySettings windowSettings = new DisplaySettings(1024, 768, 24, 2); final LwjglCanvasRenderer canvasRenderer = new LwjglCanvasRenderer(this); canvas = new LwjglCanvas(canvasRenderer, windowSettings); logicalLayer = new LogicalLayer(); physicalLayer = new PhysicalLayer(new LwjglKeyboardWrapper(), new LwjglMouseWrapper(), new DummyControllerWrapper(), (LwjglCanvas) canvas); logicalLayer.registerInput(canvas, physicalLayer); canvas.setTitle("DVSF Model converter"); canvas.init();// w w w . j ava 2 s.com // cameraNode = new CameraNode("Cam node" , canvas.getCanvasRenderer().getCamera()); // cameraController = new AlwaysUpCameraControl(logicalLayer, Vector3.UNIT_Z, 0, 0, 10); // rootNode.attachChild(cameraNode); // ResourceLocator modelResourceLoader = new ClasspathResourceLocator("models"); // ResourceLocator textureLoader = new ResourceLocator() { // private ResourceLocator delegateLoader = new ClasspathResourceLocator("models"); // public ResourceSource locateResource(String resourceName) { // //resourceName = resourceName.toLowerCase().replace(".jpg", ".tga"); // resourceName = resourceName.toLowerCase().replace("sf-bump", "sf-norm"); // return delegateLoader.locateResource(resourceName); // } // }; // ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL, modelResourceLoader); // ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, textureLoader); ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, new SimpleResourceLocator(new URL("file:///Users/gabor/ardor3d-svn/trunk/data/textures"))); ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL, new SimpleResourceLocator(new URL("file:///Users/gabor/ardor3d-svn/trunk"))); Node model = load3DSModel("./data/3ds/vase.3ds"); rootNode.attachChild(model); canvas.getCanvasRenderer().getCamera().setLocation(5, 5, 10); canvas.getCanvasRenderer().getCamera().lookAt(model.getTranslation(), Vector3.UNIT_Y); // rootNode.attachChild(new AxisRods("AxisRods", true, 30, 0.05)); // SimpleResourceLocator backgroundResourceLoader = new SimpleResourceLocator(Thread.currentThread().getContextClassLoader().getResource("backgrounds")); // ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, backgroundResourceLoader); final ZBufferState buf = new ZBufferState(); buf.setEnabled(true); buf.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo); rootNode.setRenderState(buf); // ---- LIGHTS /** Set up a basic, default light. */ final PointLight light = new PointLight(); // light.setSpecular(ColorRGBA.GREEN); // light.setDiffuse(ColorRGBA.GREEN); // light.setAmbient(ColorRGBA.GREEN); light.setSpecular(ColorRGBA.GREEN); light.setDiffuse(new ColorRGBA(0.5f, 0.75f, 0.5f, 0.75f)); light.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f)); light.setLocation(new Vector3(900, 900, 900)); // DirectionalLight light = new DirectionalLight(); // light.setAmbient(new ColorRGBA(0.75f, 0.75f, 0.75f, 1)); // light.setDiffuse(new ColorRGBA(1, 1, 1, 1)); // light.setEnabled(true); light.setEnabled(true); /** Attach the light to a lightState and the lightState to rootNode. */ LightState lightState = new LightState(); lightState.setEnabled(true); lightState.attach(light); rootNode.setRenderState(lightState); CullState cs = new CullState(); cs.setCullFace(CullState.Face.Back); cs.setEnabled(true); rootNode.setRenderState(cs); //rootNode.getSceneHints().setDataMode(DataMode.VBO); Debugger.setBoundsColor(new ColorRGBA(ColorRGBA.WHITE)); Debugger.NORMAL_COLOR_BASE.set(ColorRGBA.WHITE); Debugger.NORMAL_COLOR_TIP.set(ColorRGBA.WHITE); while (!exit) { if (canvas.isClosing()) { exit = true; } timer.update(); logicalLayer.checkTriggers(timer.getTimePerFrame()); //Force this to be called first // cameraController.update(timer.getTimePerFrame(), cameraNode); // angle += 2 * timer.getTimePerFrame(); // LightState lightState = (LightState) rootNode.getLocalRenderState(StateType.Light); // ((DirectionalLight)lightState.get(0)).setDirection(new Vector3(2.0f * // Math.cos(angle), 2.0f * Math.sin(angle), 1.5f)); // Update controllers/render states/transforms/bounds for rootNode. rootNode.updateGeometricState(timer.getTimePerFrame(), true); canvas.draw(null); Thread.yield(); } // ContextGarbageCollector.doFinalCleanup(canvas.getCanvasRenderer().getRenderer()); canvas.close(); }
From source file:org.apache.hadoop.hbase.rest.RowResourceBase.java
protected static Response checkAndPutValueXML(String url, String table, String row, String column, String valueToCheck, String valueToPut, HashMap<String, String> otherCells) throws IOException, JAXBException { RowModel rowModel = new RowModel(row); rowModel.addCell(new CellModel(Bytes.toBytes(column), Bytes.toBytes(valueToPut))); if (otherCells != null) { for (Map.Entry<String, String> entry : otherCells.entrySet()) { rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), Bytes.toBytes(entry.getValue()))); }//from w w w .j a va 2 s. co m } // This Cell need to be added as last cell. rowModel.addCell(new CellModel(Bytes.toBytes(column), Bytes.toBytes(valueToCheck))); CellSetModel cellSetModel = new CellSetModel(); cellSetModel.addRow(rowModel); StringWriter writer = new StringWriter(); xmlMarshaller.marshal(cellSetModel, writer); Response response = client.put(url, Constants.MIMETYPE_XML, Bytes.toBytes(writer.toString())); Thread.yield(); return response; }
From source file:net.jradius.server.TCPListener.java
/** * The thread's run method repeatedly calls listen() *//*from w w w . j a v a 2 s . com*/ public void run() { while (getActive()) { try { Thread.yield(); listen(); } catch (SocketException e) { if (getActive() == false) { break; } else { RadiusLog.error("Socket exception", e); } } catch (InterruptedException e) { } catch (SSLException e) { RadiusLog.error("Error occured in TCPListener.", e); active = false; } catch (Throwable e) { RadiusLog.error("Error occured in TCPListener.", e); } } RadiusLog.debug("Listener: " + this.getClass().getName() + " exiting (not active)"); }