Java Code Examples for org.mortbay.log.Log

The following are top voted examples for showing how to use org.mortbay.log.Log. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Reer   File: JettyConfiguration.java   Source Code and License 6 votes vote down vote up
/**
 * Set up the classloader for the webapp, using the various parts of the Maven project
 *
 * @see org.mortbay.jetty.webapp.Configuration#configureClassLoader()
 */
public void configureClassLoader() throws Exception {
    if (classPathFiles != null) {
        Log.debug("Setting up classpath ...");

        //put the classes dir and all dependencies into the classpath
        for (File classPathFile : classPathFiles) {
            ((WebAppClassLoader) getWebAppContext().getClassLoader()).addClassPath(
                    classPathFile.getCanonicalPath());
        }

        if (Log.isDebugEnabled()) {
            Log.debug("Classpath = " + LazyList.array2List(
                    ((URLClassLoader) getWebAppContext().getClassLoader()).getURLs()));
        }
    } else {
        super.configureClassLoader();
    }
}
 
Example 2
Project: hadoop-oss   File: TestAuthenticationSessionCookie.java   Source Code and License 6 votes vote down vote up
@Test
public void testSessionCookie() throws IOException {
  try {
      startServer(true);
  } catch (Exception e) {
      // Auto-generated catch block
      e.printStackTrace();
  }

  URL base = new URL("http://" + NetUtils.getHostPortString(server
          .getConnectorAddress(0)));
  HttpURLConnection conn = (HttpURLConnection) new URL(base,
          "/echo").openConnection();

  String header = conn.getHeaderField("Set-Cookie");
  List<HttpCookie> cookies = HttpCookie.parse(header);
  Assert.assertTrue(!cookies.isEmpty());
  Log.info(header);
  Assert.assertFalse(header.contains("; Expires="));
  Assert.assertTrue("token".equals(cookies.get(0).getValue()));
}
 
Example 3
Project: hadoop-oss   File: TestAuthenticationSessionCookie.java   Source Code and License 6 votes vote down vote up
@Test
public void testPersistentCookie() throws IOException {
  try {
      startServer(false);
  } catch (Exception e) {
      // Auto-generated catch block
      e.printStackTrace();
  }

  URL base = new URL("http://" + NetUtils.getHostPortString(server
          .getConnectorAddress(0)));
  HttpURLConnection conn = (HttpURLConnection) new URL(base,
          "/echo").openConnection();

  String header = conn.getHeaderField("Set-Cookie");
  List<HttpCookie> cookies = HttpCookie.parse(header);
  Assert.assertTrue(!cookies.isEmpty());
  Log.info(header);
  Assert.assertTrue(header.contains("; Expires="));
  Assert.assertTrue("token".equals(cookies.get(0).getValue()));
}
 
Example 4
Project: hadoop   File: TestAMRMClient.java   Source Code and License 6 votes vote down vote up
private int getAllocatedContainersNumber(
    AMRMClientImpl<ContainerRequest> amClient, int iterationsLeft)
    throws YarnException, IOException {
  int allocatedContainerCount = 0;
  while (iterationsLeft-- > 0) {
    Log.info(" == alloc " + allocatedContainerCount + " it left " + iterationsLeft);
    AllocateResponse allocResponse = amClient.allocate(0.1f);
    assertEquals(0, amClient.ask.size());
    assertEquals(0, amClient.release.size());
      
    assertEquals(nodeCount, amClient.getClusterNodeCount());
    allocatedContainerCount += allocResponse.getAllocatedContainers().size();
      
    if(allocatedContainerCount == 0) {
      // sleep to let NM's heartbeat to RM and trigger allocations
      sleep(100);
    }
  }
  return allocatedContainerCount;
}
 
Example 5
Project: hadoop   File: JobEndNotifier.java   Source Code and License 6 votes vote down vote up
/**
 * Notify the URL just once. Use best effort.
 */
protected boolean notifyURLOnce() {
  boolean success = false;
  try {
    Log.info("Job end notification trying " + urlToNotify);
    HttpURLConnection conn =
      (HttpURLConnection) urlToNotify.openConnection(proxyToUse);
    conn.setConnectTimeout(timeout);
    conn.setReadTimeout(timeout);
    conn.setAllowUserInteraction(false);
    if(conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
      Log.warn("Job end notification to " + urlToNotify +" failed with code: "
      + conn.getResponseCode() + " and message \"" + conn.getResponseMessage()
      +"\"");
    }
    else {
      success = true;
      Log.info("Job end notification to " + urlToNotify + " succeeded");
    }
  } catch(IOException ioe) {
    Log.warn("Job end notification to " + urlToNotify + " failed", ioe);
  }
  return success;
}
 
Example 6
Project: aliyun-oss-hadoop-fs   File: MockResourceManagerFacade.java   Source Code and License 6 votes vote down vote up
@Override
public RegisterApplicationMasterResponse registerApplicationMaster(
    RegisterApplicationMasterRequest request) throws YarnException,
    IOException {
  String amrmToken = getAppIdentifier();
  Log.info("Registering application attempt: " + amrmToken);

  synchronized (applicationContainerIdMap) {
    Assert.assertFalse("The application id is already registered: "
        + amrmToken, applicationContainerIdMap.containsKey(amrmToken));
    // Keep track of the containers that are returned to this application
    applicationContainerIdMap.put(amrmToken,
        new ArrayList<ContainerId>());
  }

  return RegisterApplicationMasterResponse.newInstance(null, null, null,
      null, null, request.getHost(), null);
}
 
Example 7
Project: aliyun-oss-hadoop-fs   File: MockResourceManagerFacade.java   Source Code and License 6 votes vote down vote up
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  String amrmToken = getAppIdentifier();
  Log.info("Finishing application attempt: " + amrmToken);

  synchronized (applicationContainerIdMap) {
    // Remove the containers that were being tracked for this application
    Assert.assertTrue("The application id is NOT registered: "
        + amrmToken, applicationContainerIdMap.containsKey(amrmToken));
    List<ContainerId> ids = applicationContainerIdMap.remove(amrmToken);
    for (ContainerId c : ids) {
      allocatedContainerMap.remove(c);
    }
  }

  return FinishApplicationMasterResponse
      .newInstance(request.getFinalApplicationStatus() == FinalApplicationStatus.SUCCEEDED ? true
          : false);
}
 
Example 8
Project: aliyun-oss-hadoop-fs   File: TestAMRMClient.java   Source Code and License 6 votes vote down vote up
private int getAllocatedContainersNumber(
    AMRMClientImpl<ContainerRequest> amClient, int iterationsLeft)
    throws YarnException, IOException {
  int allocatedContainerCount = 0;
  while (iterationsLeft-- > 0) {
    Log.info(" == alloc " + allocatedContainerCount + " it left " + iterationsLeft);
    AllocateResponse allocResponse = amClient.allocate(0.1f);
    assertEquals(0, amClient.ask.size());
    assertEquals(0, amClient.release.size());
      
    assertEquals(nodeCount, amClient.getClusterNodeCount());
    allocatedContainerCount += allocResponse.getAllocatedContainers().size();
      
    if(allocatedContainerCount == 0) {
      // sleep to let NM's heartbeat to RM and trigger allocations
      sleep(100);
    }
  }
  return allocatedContainerCount;
}
 
Example 9
Project: aliyun-oss-hadoop-fs   File: JobEndNotifier.java   Source Code and License 6 votes vote down vote up
/**
 * Notify the URL just once. Use best effort.
 */
protected boolean notifyURLOnce() {
  boolean success = false;
  try {
    Log.info("Job end notification trying " + urlToNotify);
    HttpURLConnection conn =
      (HttpURLConnection) urlToNotify.openConnection(proxyToUse);
    conn.setConnectTimeout(timeout);
    conn.setReadTimeout(timeout);
    conn.setAllowUserInteraction(false);
    if(conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
      Log.warn("Job end notification to " + urlToNotify +" failed with code: "
      + conn.getResponseCode() + " and message \"" + conn.getResponseMessage()
      +"\"");
    }
    else {
      success = true;
      Log.info("Job end notification to " + urlToNotify + " succeeded");
    }
  } catch(IOException ioe) {
    Log.warn("Job end notification to " + urlToNotify + " failed", ioe);
  }
  return success;
}
 
Example 10
Project: aliyun-oss-hadoop-fs   File: TestAuthenticationSessionCookie.java   Source Code and License 6 votes vote down vote up
@Test
public void testSessionCookie() throws IOException {
  try {
      startServer(true);
  } catch (Exception e) {
      // Auto-generated catch block
      e.printStackTrace();
  }

  URL base = new URL("http://" + NetUtils.getHostPortString(server
          .getConnectorAddress(0)));
  HttpURLConnection conn = (HttpURLConnection) new URL(base,
          "/echo").openConnection();

  String header = conn.getHeaderField("Set-Cookie");
  List<HttpCookie> cookies = HttpCookie.parse(header);
  Assert.assertTrue(!cookies.isEmpty());
  Log.info(header);
  Assert.assertFalse(header.contains("; Expires="));
  Assert.assertTrue("token".equals(cookies.get(0).getValue()));
}
 
Example 11
Project: aliyun-oss-hadoop-fs   File: TestAuthenticationSessionCookie.java   Source Code and License 6 votes vote down vote up
@Test
public void testPersistentCookie() throws IOException {
  try {
      startServer(false);
  } catch (Exception e) {
      // Auto-generated catch block
      e.printStackTrace();
  }

  URL base = new URL("http://" + NetUtils.getHostPortString(server
          .getConnectorAddress(0)));
  HttpURLConnection conn = (HttpURLConnection) new URL(base,
          "/echo").openConnection();

  String header = conn.getHeaderField("Set-Cookie");
  List<HttpCookie> cookies = HttpCookie.parse(header);
  Assert.assertTrue(!cookies.isEmpty());
  Log.info(header);
  Assert.assertTrue(header.contains("; Expires="));
  Assert.assertTrue("token".equals(cookies.get(0).getValue()));
}
 
Example 12
Project: openbravo-pos   File: JettyHttpServer.java   Source Code and License 6 votes vote down vote up
private void cleanUpConnectors()
   {
	Iterator<Map.Entry<String, Connector>> it = _connectors.entrySet().iterator();
	while (it.hasNext())
	{
		Map.Entry<String, Connector> entry = (Map.Entry<String, Connector>) it.next();
		Connector connector = entry.getValue();
		try
		{
			connector.stop();
		} catch (Exception ex)
		{
			Log.warn(ex);
		}
		_server.removeConnector(connector);
	}
	_connectors.clear();
}
 
Example 13
Project: openbravo-pos   File: GigaServer.java   Source Code and License 6 votes vote down vote up
public void afterPropertiesSet() throws Exception 
{
	// not the right place to write out a full on configuration object, server not initialized, but this does appear
	// to write out an object.  Need to work out the reading and writing bit, maybe try a consolidated configuration object with a
	// a map of configurations keys by a unique key based on clusterInfo and then read/write that.  would want to ensure its
	// unique though, so maybe instance Id 1 would be the only one allowed to create it, others would block?
	
	// of course this is dependent on the space setting, currently configured with in jvm space only, is this the default
	// way we want to do it?
	gigaSpace.write( new GigaServerConfiguration( _clusterInfo, this ) );
	
	GigaServerConfiguration gsc = gigaSpace.read( new GigaServerConfiguration() );
	
	if ( gsc == null )
	{
		Log.info( "GSC is null :(" );	
	}
	else
	{
		Log.info( "GSC is not null and  server port is " + gsc.getServerPort() );  // currently 0, need another place for doing this
	}
}
 
Example 14
Project: openbravo-pos   File: GigaSessionManager.java   Source Code and License 6 votes vote down vote up
/**
 * Session from a request.
 * 
 * @param request
 */
protected Session (HttpServletRequest request)
{
 
    super(request);   
    _data = new SessionData(_clusterId);
    _data.setMaxIdleMs(_dftMaxIdleSecs*1000);
    _data.setContextPath(_context.getContextPath());
    _data.setVirtualHost(getVirtualHost(_context));
    _data.setExpiryTime(_maxIdleMs < 0 ? 0 : (System.currentTimeMillis() + _maxIdleMs));
    _data.setCookieSet(0);
    if (_data.getAttributeMap()==null)
        newAttributeMap();
    _values=_data.getAttributeMap();
    if (Log.isDebugEnabled()) Log.debug("New Session from request, "+_data.toStringExtended());
}
 
Example 15
Project: openbravo-pos   File: GigaSessionManager.java   Source Code and License 6 votes vote down vote up
/** 
 * Exit from session
 * 
 * If the session attributes changed then always write the session 
 * to the cloud.
 * 
 * If just the session access time changed, we don't always write out the
 * session, because the gigaspace will serialize the unchanged sesssion
 * attributes. To save on serialization overheads, we only write out the
 * session when only the access time has changed if the time at which we
 * last saved the session exceeds the chosen save interval.
 * 
 * @see org.mortbay.jetty.servlet.AbstractSessionManager.Session#complete()
 */
protected void complete()
{
    super.complete();
    try
    {
        if (_dirty || (_data._accessed - _data._lastSaved) >= (_savePeriodMs))
        {
            _data.setLastSaved(System.currentTimeMillis());
            willPassivate();   
            update(_data);
            didActivate();
            if (Log.isDebugEnabled()) Log.debug("Dirty="+_dirty+", accessed-saved="+_data._accessed +"-"+ _data._lastSaved+", savePeriodMs="+_savePeriodMs);
        }
    }
    catch (Exception e)
    {
        Log.warn("Problem persisting changed session data id="+getId(), e);
    }
    finally
    {
        _dirty=false;
    }
}
 
Example 16
Project: openbravo-pos   File: GigaSessionManager.java   Source Code and License 6 votes vote down vote up
protected void addSession(org.mortbay.jetty.servlet.AbstractSessionManager.Session abstractSession)
{
    if (abstractSession==null)
        return;
    
    if (!(abstractSession instanceof GigaSessionManager.Session))
            throw new IllegalStateException("Not a GigaspacesSessionManager.Session "+abstractSession);
    
    synchronized (this)
    {
        GigaSessionManager.Session session = (GigaSessionManager.Session)abstractSession;

        try
        {
            _sessions.put(getClusterId(session), session);
            add(session._data);
        }
        catch (Exception e)
        {
            Log.warn("Problem writing new SessionData to space ", e);
        }
    } 
}
 
Example 17
Project: openbravo-pos   File: GigaSessionIdManager.java   Source Code and License 6 votes vote down vote up
public void addSession(HttpSession session)
{
    if (session == null)
        return;
    
    synchronized (_sessionIds)
    {
        if (session instanceof GigaSessionManager.Session)
        {
            String id = ((GigaSessionManager.Session)session).getClusterId();            
            try
            {
                Id theId = new Id(id);
                add(theId);
                _sessionIds.add(theId);
                if (Log.isDebugEnabled()) Log.debug("Added id "+id);
            }
            catch (Exception e)
            {
                Log.warn("Problem storing session id="+id, e);
            }
        }
        else
            throw new IllegalStateException ("Session is not a Gigaspaces session");
    }
}
 
Example 18
Project: openbravo-pos   File: GigaSessionIdManager.java   Source Code and License 6 votes vote down vote up
public boolean idInUse(String id)
{
    if (id == null)
        return false;
    
    String clusterId = getClusterId(id);
    Id theId = new Id(clusterId);
    synchronized (_sessionIds)
    {
        if (_sessionIds.contains(theId))
            return true; //optimisation - if this session is one we've been managing, we can check locally
        
        //otherwise, we need to go to the space to check
        try
        {
            return exists(theId);
        }
        catch (Exception e)
        {
            Log.warn("Problem checking inUse for id="+clusterId, e);
            return false;
        }
    }
}
 
Example 19
Project: openbravo-pos   File: GigaSessionIdManager.java   Source Code and License 6 votes vote down vote up
public void removeSession (String id)
{

    if (id == null)
        return;
    
    synchronized (_sessionIds)
    {  
        if (Log.isDebugEnabled())
            Log.debug("Removing session id="+id);
        try
        {               
            Id theId = new Id(id);
            _sessionIds.remove(theId);
            delete(theId);
        }
        catch (Exception e)
        {
            Log.warn("Problem removing session id="+id, e);
        }
    }
    
}
 
Example 20
Project: openbravo-pos   File: TerracottaSessionManager.java   Source Code and License 6 votes vote down vote up
protected void removeSession(String clusterId)
{
    /**
     * SESSION LOCKING
     * When this method is called, we already hold the session lock.
     * Either the scavenger acquired it, or the user invalidated
     * the existing session and thus {@link #enter(String)} was called.
     */

    // Remove locally cached session
    Session session = _sessions.remove(clusterId);
    Log.debug("Removed session {} with id {}", session, clusterId);

    // It may happen that one node removes its expired session data,
    // so that when this node does the same, the session data is already gone
    SessionData sessionData = _sessionDatas.remove(clusterId);
    Log.debug("Removed session data {} with id {}", sessionData, clusterId);

    // Remove the expiration entry used in scavenging
    _sessionExpirations.remove(clusterId);
}
 
Example 21
Project: openbravo-pos   File: TerracottaSessionManager.java   Source Code and License 6 votes vote down vote up
public static void unlock(String lockId)
{
    Integer nestingLevel = nestings.get().get(lockId);
    if (nestingLevel == null || nestingLevel < 1)
        throw new AssertionError("Lock(" + lockId + ") nest level = " + nestingLevel + ", thread " + Thread.currentThread() + ": " + nestings.get());
    if (nestingLevel == 1)
    {
        ManagerUtil.commitLock(lockId);
        Log.debug("Lock({}) released by thread {}", lockId, Thread.currentThread().getName());
        nestings.get().remove(lockId);
    }
    else
    {
        nestings.get().put(lockId, nestingLevel - 1);
    }
    Log.debug("Lock({}) nestings {}", lockId, nestings.get());
}
 
Example 22
Project: openbravo-pos   File: TerracottaSessionIdManager.java   Source Code and License 6 votes vote down vote up
public void doStart()
{
    if (_random == null)
    {
        try
        {
            _random = SecureRandom.getInstance(SESSION_ID_RANDOM_ALGORITHM);
        }
        catch (NoSuchAlgorithmException e)
        {
            try
            {
                _random = SecureRandom.getInstance(SESSION_ID_RANDOM_ALGORITHM_ALT);
                _weakRandom = false;
            }
            catch (NoSuchAlgorithmException e_alt)
            {
                Log.warn("Could not generate SecureRandom for session-id randomness", e);
                _random = new Random();
                _weakRandom = true;
            }
        }
    }
    _random.setSeed(_random.nextLong() ^ System.currentTimeMillis() ^ hashCode() ^ Runtime.getRuntime().freeMemory());
    _sessionIds = newSessionIdsSet();
}
 
Example 23
Project: openbravo-pos   File: BayeuxClient.java   Source Code and License 6 votes vote down vote up
protected void setMessages(Queue<Message> messages)
{
    try
    {
        for (Message msg : messages)
        {
            msg.put(Bayeux.CLIENT_FIELD,_clientId);
        }
        String json=JSON.toString(messages);

        if (_formEncoded)
            setRequestContent(new ByteArrayBuffer("message="+URLEncoder.encode(json,"utf-8")));
        else
            setRequestContent(new ByteArrayBuffer(json,"utf-8"));

    }
    catch (Exception e)
    {
        Log.warn(e);
    }

}
 
Example 24
Project: openbravo-pos   File: BayeuxClient.java   Source Code and License 6 votes vote down vote up
Connect()
{
    super("connect");
    String connect="{"+"\"channel\":\"/meta/connect\","+"\"clientId\":\""+_clientId+"\","+"\"connectionType\":\"long-polling\""+"}";
    setMessage(connect);

    try
    {
        customize(this);
        _client.send(this);
    }
    catch (IOException e)
    {
        Log.warn(e);
    }
}
 
Example 25
Project: openbravo-pos   File: BayeuxClient.java   Source Code and License 6 votes vote down vote up
Publish()
{
    super("publish");
    synchronized (_outQ)
    {
        if (_outQ.size()==0)
            return;
        setMessages(_outQ);
        _outQ.clear();
    }
    try
    {
        customize(this);
        _client.send(this);
    }
    catch (IOException e)
    {
        Log.warn(e);
    }
}
 
Example 26
Project: openbravo-pos   File: GrizzlyConnector.java   Source Code and License 6 votes vote down vote up
public void accept(int acceptorID) throws IOException
{
    try
    {
        // TODO - this may not exactly be right.  accept is called in a loop, so we
        // may need to wait on the _selectorThread somehow?
        // maybe we just set acceptors to zero and don't need to bother here as
        // grizzly has it's own accepting threads.
        if (controller.isStarted())
        {
            Thread.sleep(5000);
        }
        
    }
    catch (Throwable e)
    {
        // TODO Auto-generated catch block
        Log.ignore(e);
    }
    
}
 
Example 27
Project: big-c   File: TestAMRMClient.java   Source Code and License 6 votes vote down vote up
private int getAllocatedContainersNumber(
    AMRMClientImpl<ContainerRequest> amClient, int iterationsLeft)
    throws YarnException, IOException {
  int allocatedContainerCount = 0;
  while (iterationsLeft-- > 0) {
    Log.info(" == alloc " + allocatedContainerCount + " it left " + iterationsLeft);
    AllocateResponse allocResponse = amClient.allocate(0.1f);
    assertEquals(0, amClient.ask.size());
    assertEquals(0, amClient.release.size());
      
    assertEquals(nodeCount, amClient.getClusterNodeCount());
    allocatedContainerCount += allocResponse.getAllocatedContainers().size();
      
    if(allocatedContainerCount == 0) {
      // sleep to let NM's heartbeat to RM and trigger allocations
      sleep(100);
    }
  }
  return allocatedContainerCount;
}
 
Example 28
Project: big-c   File: JobEndNotifier.java   Source Code and License 6 votes vote down vote up
/**
 * Notify the URL just once. Use best effort.
 */
protected boolean notifyURLOnce() {
  boolean success = false;
  try {
    Log.info("Job end notification trying " + urlToNotify);
    HttpURLConnection conn =
      (HttpURLConnection) urlToNotify.openConnection(proxyToUse);
    conn.setConnectTimeout(timeout);
    conn.setReadTimeout(timeout);
    conn.setAllowUserInteraction(false);
    if(conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
      Log.warn("Job end notification to " + urlToNotify +" failed with code: "
      + conn.getResponseCode() + " and message \"" + conn.getResponseMessage()
      +"\"");
    }
    else {
      success = true;
      Log.info("Job end notification to " + urlToNotify + " succeeded");
    }
  } catch(IOException ioe) {
    Log.warn("Job end notification to " + urlToNotify + " failed", ioe);
  }
  return success;
}
 
Example 29
Project: ryf_mms2   File: OperInfoSelectPassService.java   Source Code and License 6 votes vote down vote up
public Object doRequest(Map<String, Object> params) {
LogUtil.printInfoLog(params);

Object mtype = params.get("mtype");
if (mtype == null) {
	Log.info("类型不能为空");
	return null;
}
Object operId = params.get("operId");
if (operId == null) {
	Log.info("操作员号不能为空");
	return null;
}
String mid = (String)params.get("mid");
if(Ryt.empty(mid)){
	return "商户号不能为空";
}

String resultCode = new MerOperDao().getOldPass(Integer.valueOf(mtype.toString()), Integer.valueOf(operId.toString()), mid);
JSONObject pageObj = new JSONObject();//总json对象
pageObj.put("resultCode", resultCode);
return pageObj;
}
 
Example 30
Project: flume-ng-druid-sink   File: FlumeEventParser.java   Source Code and License 6 votes vote down vote up
private Map<String, Object> parseEvent(Event event) throws FlumeEventParserException {
    Map<String, Object> parsedEvent;
    if (event != null && !event.getHeaders().isEmpty()) {
        final Map<String, String> headers = event.getHeaders();
        Log.debug("Headers: {}", headers);
        parsedEvent = new HashMap<String, Object>();
        Log.debug("Header keys: {}", headers.keySet());
        for (String header : headers.keySet()) {
            if (filter.contains(header)) {
                if (headers.get(timestampField) != null && timestampField.equals(header)) {
                    parsedEvent.put(timestampField, headers.get(timestampField));
                    //TODO create timestamp field when timestampField is null?
                    //parsedEvent.put(timestampField, new DateTime(DateTimeZone.UTC).toString(dateTimeFormatter));
                    //parsedEvent.put("timestamp", new DateTime(DateTimeZone.UTC).getMillis());
                } else if (headers.get(header) != null) {
                    parsedEvent.put(header, headers.get(header));
                }
            }
        }
    } else {
        throw new FlumeEventParserException("Event is null or headers are empty");
    }

    return parsedEvent;
}
 
Example 31
Project: Camel   File: AvroListener.java   Source Code and License 6 votes vote down vote up
/**
 * Unregisters consumer by message name.
 * Stops server in case if all consumers are unregistered and default consumer is absent or stopped.
 *
 * @param messageName message name
 * @return true if all consumers are unregistered and defaultConsumer is absent or null.
 *         It means that this responder can be unregistered.
 */
public boolean unregister(String messageName) {
    if (!StringUtils.isEmpty(messageName)) {
        if (consumerRegistry.remove(messageName) == null) {
            Log.warn("Consumer with message name " + messageName + " was already unregistered.");
        }
    } else {
        defaultConsumer = null;
    }

    if ((defaultConsumer == null) && (consumerRegistry.isEmpty())) {
        if (server != null) {
            server.close();
        }
        return true;
    }
    return false;
}
 
Example 32
Project: hadoop-2.6.0-cdh5.4.3   File: TestAMRMClient.java   Source Code and License 6 votes vote down vote up
private int getAllocatedContainersNumber(
    AMRMClientImpl<ContainerRequest> amClient, int iterationsLeft)
    throws YarnException, IOException {
  int allocatedContainerCount = 0;
  while (iterationsLeft-- > 0) {
    Log.info(" == alloc " + allocatedContainerCount + " it left " + iterationsLeft);
    AllocateResponse allocResponse = amClient.allocate(0.1f);
    assertEquals(0, amClient.ask.size());
    assertEquals(0, amClient.release.size());
      
    assertEquals(nodeCount, amClient.getClusterNodeCount());
    allocatedContainerCount += allocResponse.getAllocatedContainers().size();
      
    if(allocatedContainerCount == 0) {
      // sleep to let NM's heartbeat to RM and trigger allocations
      sleep(100);
    }
  }
  return allocatedContainerCount;
}
 
Example 33
Project: hadoop-2.6.0-cdh5.4.3   File: JobEndNotifier.java   Source Code and License 6 votes vote down vote up
/**
 * Notify the URL just once. Use best effort.
 */
protected boolean notifyURLOnce() {
  boolean success = false;
  try {
    Log.info("Job end notification trying " + urlToNotify);
    HttpURLConnection conn =
      (HttpURLConnection) urlToNotify.openConnection(proxyToUse);
    conn.setConnectTimeout(timeout);
    conn.setReadTimeout(timeout);
    conn.setAllowUserInteraction(false);
    if(conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
      Log.warn("Job end notification to " + urlToNotify +" failed with code: "
      + conn.getResponseCode() + " and message \"" + conn.getResponseMessage()
      +"\"");
    }
    else {
      success = true;
      Log.info("Job end notification to " + urlToNotify + " succeeded");
    }
  } catch(IOException ioe) {
    Log.warn("Job end notification to " + urlToNotify + " failed", ioe);
  }
  return success;
}
 
Example 34
Project: hadoop-2.6.0-cdh5.4.3   File: TestJobHistoryConfig.java   Source Code and License 6 votes vote down vote up
/**
 * Check whether the JobTracker can be started.
 * 
 * @throws IOException
 */
private boolean canStartJobTracker(JobConf conf) throws InterruptedException,
    IOException {
  JobTracker jt = null;
  try {
    jt = JobTracker.startTracker(conf);
    Log.info("Started JobTracker");
  } catch (IOException e) {
    Log.info("Can not Start JobTracker", e.getLocalizedMessage());
    return false;
  }
  if (jt != null) {
    jt.fs.close();
    jt.stopTracker();
  }
  return true;
}
 
Example 35
Project: hadoop-plus   File: ContainerLogsPage.java   Source Code and License 6 votes vote down vote up
static List<File> getContainerLogDirs(ContainerId containerId,
    LocalDirsHandlerService dirsHandler) {
  List<String> logDirs = dirsHandler.getLogDirs();
  List<File> containerLogDirs = new ArrayList<File>(logDirs.size());
  for (String logDir : logDirs) {
    try {
      logDir = new URI(logDir).getPath();
    } catch (URISyntaxException e) {
      Log.warn(e.getMessage());
    }
    String appIdStr = ConverterUtils.toString(containerId
        .getApplicationAttemptId().getApplicationId());
    File appLogDir = new File(logDir, appIdStr);
    String containerIdStr = ConverterUtils.toString(containerId);
    containerLogDirs.add(new File(appLogDir, containerIdStr));
  }
  return containerLogDirs;
}
 
Example 36
Project: hadoop-plus   File: JobEndNotifier.java   Source Code and License 6 votes vote down vote up
/**
 * Notify the URL just once. Use best effort.
 */
protected boolean notifyURLOnce() {
  boolean success = false;
  try {
    Log.info("Job end notification trying " + urlToNotify);
    HttpURLConnection conn =
      (HttpURLConnection) urlToNotify.openConnection(proxyToUse);
    conn.setConnectTimeout(timeout);
    conn.setReadTimeout(timeout);
    conn.setAllowUserInteraction(false);
    if(conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
      Log.warn("Job end notification to " + urlToNotify +" failed with code: "
      + conn.getResponseCode() + " and message \"" + conn.getResponseMessage()
      +"\"");
    }
    else {
      success = true;
      Log.info("Job end notification to " + urlToNotify + " succeeded");
    }
  } catch(IOException ioe) {
    Log.warn("Job end notification to " + urlToNotify + " failed", ioe);
  }
  return success;
}
 
Example 37
Project: Pushjet-Android   File: JettyConfiguration.java   Source Code and License 6 votes vote down vote up
/**
 * Set up the classloader for the webapp, using the various parts of the Maven project
 *
 * @see org.mortbay.jetty.webapp.Configuration#configureClassLoader()
 */
public void configureClassLoader() throws Exception {
    if (classPathFiles != null) {
        Log.debug("Setting up classpath ...");

        //put the classes dir and all dependencies into the classpath
        for (File classPathFile : classPathFiles) {
            ((WebAppClassLoader) getWebAppContext().getClassLoader()).addClassPath(
                    classPathFile.getCanonicalPath());
        }

        if (Log.isDebugEnabled()) {
            Log.debug("Classpath = " + LazyList.array2List(
                    ((URLClassLoader) getWebAppContext().getClassLoader()).getURLs()));
        }
    } else {
        super.configureClassLoader();
    }
}
 
Example 38
Project: Pushjet-Android   File: JettyConfiguration.java   Source Code and License 6 votes vote down vote up
/**
 * Set up the classloader for the webapp, using the various parts of the Maven project
 *
 * @see org.mortbay.jetty.webapp.Configuration#configureClassLoader()
 */
public void configureClassLoader() throws Exception {
    if (classPathFiles != null) {
        Log.debug("Setting up classpath ...");

        //put the classes dir and all dependencies into the classpath
        for (File classPathFile : classPathFiles) {
            ((WebAppClassLoader) getWebAppContext().getClassLoader()).addClassPath(
                    classPathFile.getCanonicalPath());
        }

        if (Log.isDebugEnabled()) {
            Log.debug("Classpath = " + LazyList.array2List(
                    ((URLClassLoader) getWebAppContext().getClassLoader()).getURLs()));
        }
    } else {
        super.configureClassLoader();
    }
}
 
Example 39
Project: pbase   File: TestClassFinder.java   Source Code and License 6 votes vote down vote up
@Test
public void testClassFinderFiltersByNameInJar() throws Exception {
  final long counter = testCounter.incrementAndGet();
  final String classNamePrefix = name.getMethodName();
  Log.info("Created jar " + createAndLoadJar("", classNamePrefix, counter));

  ClassFinder.FileNameFilter notExcNameFilter = new ClassFinder.FileNameFilter() {
    @Override
    public boolean isCandidateFile(String fileName, String absFilePath) {
      return !fileName.startsWith(PREFIX);
    }
  };
  ClassFinder incClassesFinder = new ClassFinder(null, notExcNameFilter, null);
  Set<Class<?>> incClasses = incClassesFinder.findClasses(
      makePackageName("", counter), false);
  assertEquals(1, incClasses.size());
  Class<?> incClass = makeClass("", classNamePrefix, counter);
  assertTrue(incClasses.contains(incClass));
}
 
Example 40
Project: pbase   File: TestClassFinder.java   Source Code and License 6 votes vote down vote up
@Test
public void testClassFinderFiltersByClassInJar() throws Exception {
  final long counter = testCounter.incrementAndGet();
  final String classNamePrefix = name.getMethodName();
  Log.info("Created jar " + createAndLoadJar("", classNamePrefix, counter));

  final ClassFinder.ClassFilter notExcClassFilter = new ClassFinder.ClassFilter() {
    @Override
    public boolean isCandidateClass(Class<?> c) {
      return !c.getSimpleName().startsWith(PREFIX);
    }
  };
  ClassFinder incClassesFinder = new ClassFinder(null, null, notExcClassFilter);
  Set<Class<?>> incClasses = incClassesFinder.findClasses(
      makePackageName("", counter), false);
  assertEquals(1, incClasses.size());
  Class<?> incClass = makeClass("", classNamePrefix, counter);
  assertTrue(incClasses.contains(incClass));
}