小编ars*_*nal的帖子

Grep跨Hadoop文件系统中的多个文件

我正在使用Hadoop,我需要找到我的Hadoop文件系统中的~100个文件中的哪一个包含某个字符串.

我可以看到我想要搜索的文件,如下所示:

bash-3.00$ hadoop fs -ls /apps/mdhi-technology/b_dps/real-time
Run Code Online (Sandbox Code Playgroud)

..which返回几个这样的条目:

-rw-r--r--   3 b_dps mdhi-technology 1073741824 2012-07-18 22:50 /apps/mdhi-technology/b_dps/HADOOP_consolidated_RT_v1x0_20120716_aa
-rw-r--r--   3 b_dps mdhi-technology 1073741824 2012-07-18 22:50 /apps/mdhi-technology/b_dps/HADOOP_consolidated_RT_v1x0_20120716_ab
Run Code Online (Sandbox Code Playgroud)

如何找到哪些包含字符串bcd4bc3e1380a56108f486a4fffbc8dc?一旦我知道,我可以手动编辑它们.

unix bash shell grep hadoop

18
推荐指数
1
解决办法
3万
查看次数

Unix命令删除第一列后的所有内容

我有一个文本文件,其中我有这样的东西 -

10.2.57.44      56538154    3028
120.149.20.197  28909678    3166
10.90.158.161   869126135   6025
Run Code Online (Sandbox Code Playgroud)

在那个文本文件中,我有大约1,000,000行,如上所述.我在SunOS环境中工作.我需要一种方法来删除该文本文件中的所有内容,只留下IP地址(上面文本文件中的第一列是IP地址).因此在运行一些unix命令后,文件应该如下所示.

10.2.57.44
120.149.20.197
10.90.158.161
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我解决一些Unix命令,它可以删除所有只留下IP地址(第一列)的东西并再次将其保存回某个文件.

所以在某些文件中输出应该是这样的 -

10.2.57.44
120.149.20.197
10.90.158.161
Run Code Online (Sandbox Code Playgroud)

unix linux sunos

18
推荐指数
2
解决办法
2万
查看次数

使用HttpClient 4.1.1避免循环重定向

如何使用HttpClient 4.1.1避免循环重定向.因为我得到这样的错误: -

executing requestGET http://home.somehost.com/Mynet/pages/cHome.xhtml HTTP/1.1
org.apache.http.client.ClientProtocolException
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:822)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
    at edu.uci.ics.crawler4j.url.WebURL.setURL(WebURL.java:122)
    at edu.uci.ics.crawler4j.crawler.CrawlController.addSeed(CrawlController.java:207)
    at edu.uci.ics.crawler4j.example.advanced.Controller.main(Controller.java:31)
Caused by: org.apache.http.client.CircularRedirectException: Circular redirect to 'http://home.somehost.com/Mynet/pages/Home.xhtml'
    at org.apache.http.impl.client.DefaultRedirectStrategy.getLocationURI(DefaultRedirectStrategy.java:168)
    at org.apache.http.impl.client.DefaultRedirectStrategy.getRedirect(DefaultRedirectStrategy.java:193)
    at org.apache.http.impl.client.DefaultRequestDirector.handleResponse(DefaultRequestDirector.java:1021)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:482)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
Run Code Online (Sandbox Code Playgroud)

这是我的代码......

DefaultHttpClient client = null;

        try
        {
            // Set url
            //URI uri = new URI(url.toString());

            client = new DefaultHttpClient();

            client.getCredentialsProvider().setCredentials(
                    new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM),
                    new UsernamePasswordCredentials("test", "test"));


            URL url1 = new URL (url);
            HttpURLConnection connection = (HttpURLConnection) url1.openConnection();
            connection.setFollowRedirects(false);

            HttpGet request = new HttpGet(url);
            final …
Run Code Online (Sandbox Code Playgroud)

java httpclient

16
推荐指数
1
解决办法
2万
查看次数

Cassandra数据库中的commitLog和SSTables

我最近开始使用Cassandra数据库.我已经安装single node cluster在我当地的盒子里.我正在与之合作Cassandra 1.2.3.

我正在网上阅读这篇文章,我发现这条线 -

Cassandra写入首先写入提交日志(用于持久性),然后写入称为memtable的内存表结构.写入提交日志和内存后写入成功,因此写入时磁盘I/O非常小.写入在内存中进行批处理,并定期写入磁盘到称为SSTable(已排序的字符串表)的持久表结构.

因此,为了理解上述内容,我编写了一个简单的程序,它将使用Cassandra数据库写入Pelops client.我能够在Cassandra数据库中插入数据.

现在我想看看我的数据是如何写入的,commit log以及它在哪里commit log file?还有如何SSTables生成以及我可以在本地框中找到它以及它包含的内容.

我想看看这两个文件,以便我能更好地了解Cassandra在幕后的工作原理.

在我的cassandra.yaml文件中,我有类似的东西

# directories where Cassandra should store data on disk.
data_file_directories:
    - S:\Apache Cassandra\apache-cassandra-1.2.3\storage\data

# commit log
commitlog_directory: S:\Apache Cassandra\apache-cassandra-1.2.3\storage\commitlog

# saved caches
saved_caches_directory: S:\Apache Cassandra\apache-cassandra-1.2.3\storage\savedcaches
Run Code Online (Sandbox Code Playgroud)

但是当我打开commitLog时,首先它有很多数据,所以我的记事本++无法正确打开它,如果它被打开,我无法正确看到因为某些编码或什么.在我的数据文件夹中,我找不到任何东西?

这个文件夹对我来说是空的 -

S:\Apache Cassandra\apache-cassandra-1.2.3\storage\data\my_keyspace\users
Run Code Online (Sandbox Code Playgroud)

这里有什么我想念的吗?任何人都可以解释我如何读取commitLog和SSTables文件以及我在哪里可以找到这两个文件?而且每当我写信给Cassandra数据库时,幕后究竟会发生什么.

更新:-

我用来插入Cassandra数据库的代码 -

public class MyPelops {

    private static final Logger log = Logger.getLogger(MyPelops.class);

    public static void main(String[] args) throws Exception { …
Run Code Online (Sandbox Code Playgroud)

cassandra nosql

15
推荐指数
1
解决办法
1万
查看次数

我们如何只能在表td标签中加粗名称而不是值

有没有办法让我可以制作CC Quid,应用程序编号,应用程序标题以及以粗体显示其他内容的方式,我不希望它们的值是粗体.任何建议将不胜感激..

html = html + "<table border ='0'>";
    html= html + "<tr>";
    html =html + "<td>CC Quid: " +(data.response.docs[0].c_cc_guid)+"</td></tr>";
    html =html + "<tr><td>Application Number: " +(data.response.docs[0].c_application_number)+"</td></tr>";
    html =html + "<tr><td>Application Title: " +(data.response.docs[0].c_application_title)+"</td></tr>";
    html =html + "<tr><td>Application Type Name: " +(data.response.docs[0].c_application_type_name)+"</td></tr>";
    html =html + "<tr><td>Case Mgr Name: " +(data.response.docs[0].c_case_mgr_name)+"</td></tr>";
    html =html + "<tr><td>Filed Date: " +(data.response.docs[0].c_filed_date)+"</td></tr>";
    html =html + "<tr><td>Lead Atny Name: " +(data.response.docs[0].c_lead_atny_name)+"</td></tr>";
    html =html + "</table>";
Run Code Online (Sandbox Code Playgroud)

html html-table

12
推荐指数
1
解决办法
11万
查看次数

java.lang.UnsupportedClassVersionError:offset = 6时的错误主要版本

我在我WAR filewebapps文件夹中部署了一个tomcat.当我开始我的tomcat时,如下所示

C:\apache-tomcat-6.0.35\bin>startup.bat
Using CATALINA_BASE:   "C:\apache-tomcat-6.0.35"
Using CATALINA_HOME:   "C:\apache-tomcat-6.0.35"
Using CATALINA_TMPDIR: "C:\apache-tomcat-6.0.35\temp"
Using JRE_HOME:        "C:\Program Files (x86)\IBM\RationalSDLC\Common\Java5.0\jre"
Using CLASSPATH:       "C:\apache-tomcat-6.0.35\bin\bootstrap.jar"
Run Code Online (Sandbox Code Playgroud)

我得到以下异常 -

SEVERE: Error deploying web application archive DirectoryServer.war
java.lang.UnsupportedClassVersionError: (com/services/rest/Listener) bad major version at offset=6 (unable to load class com.services.rest.Listener)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2822)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:145)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:73)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:56)
    at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:297)
    at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1078)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4612)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
    at …
Run Code Online (Sandbox Code Playgroud)

apache tomcat unsupported-class-version

10
推荐指数
1
解决办法
6万
查看次数

当zookeeper的状态自动更改时,Watches和Ephemeral节点不起作用?

我有一个非常奇怪的Python Kazoo库案例.我在下面的代码中做的是 -

一旦我使用kazoo库连接到Zookeeper,我创建一个短暂的节点,然后在其他节点上监视,然后我继续在无限循环中继续运行程序..我还为Zookeeper添加了一个监听器这也将监督国家.

对我来说一切都很好,短暂的节点是起来的,看我的znode也工作正常...

有时,由于连接中断或丢失,我看到很奇怪的行为.正如我上面提到的,我添加了一个监听器,动物园管理员将监视的状态,我有一个print语句以及..我总是看到,这些打印语句得到打印出来Lost,Suspended,Connected,我认为,由于连接中断,之后我的短暂节点消失了,我在znode上的监视也不起作用.

以下是我的代码,它永远运行 -

#!/usr/bin/python

from kazoo.client import KazooClient
from kazoo.client import KazooState
from kazoo.protocol.states import EventType


def watch_host(event):
    print event


def my_listener(state):
    if state == KazooState.LOST:
    # Register somewhere that the session was lost
        print "Lost"
    elif state == KazooState.SUSPENDED:
    # Handle being disconnected from Zookeeper
        print "Suspended"
    else:
    # Handle being connected/reconnected to Zookeeper
    # what are we supposed to do here?
    print "Being Connected/Reconnected"


zk = …
Run Code Online (Sandbox Code Playgroud)

python watch kazoo apache-zookeeper

10
推荐指数
2
解决办法
5498
查看次数

如何在Python中获取完全限定的主机名?

我想在Python中获取主机名.在linux中,如果我输入hostname命令提示符,我得到

root@phxdbx45:/home/david/zkpython# hostname
phxdbx45
Run Code Online (Sandbox Code Playgroud)

但是,如果我键入,hostname -f那么我会在ubuntu中获得完全限定的主机名,这也是我需要的Python.

root@phxdbx45:/home/david/zkpython# hostname -f
phxdbx45.phx.host.com
Run Code Online (Sandbox Code Playgroud)

我知道在Python中我们可以使用下面的代码,但它不会给我完全限定的主机名.它给了hostname我如上所述的输出.

#!/usr/bin/python

import socket

hostname = socket.gethostname()
print hostname
Run Code Online (Sandbox Code Playgroud)

有没有办法在Python中获得可靠且正确的完全限定主机名?

python hostname

10
推荐指数
1
解决办法
3万
查看次数

Base64Encoder无法解析

这是我在JSP文件中的Java代码.我正进入(状态

Base64Encoder无法解析.

为什么会这样?我必须添加一些相关的东西Base64Encoder.任何建议将不胜感激.

    <%@ page language="java" import="java.io.OutputStream,java.net.HttpURLConnection,java.net.URL,java.util.Collection,org.apache.commons.httpclient.Credentials,org.apache.commons.httpclient.auth.AuthenticationException,org.apache.commons.httpclient.auth.MalformedChallengeException,org.apache.commons.httpclient.params.DefaultHttpParams,org.apache.commons.httpclient.params.HttpParams,org.apache.commons.httpclient.auth.AuthScheme,org.apache.commons.httpclient.auth.AuthPolicy,org.apache.commons.httpclient.HttpClient,org.apache.commons.httpclient.UsernamePasswordCredentials,org.apache.commons.httpclient.auth.AuthScope,org.apache.commons.httpclient.methods.GetMethod,org.w3c.dom.*,javax.xml.parsers.DocumentBuilder,javax.xml.parsers.DocumentBuilderFactory,java.net.*,java.io.*" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<%
String a_Url = request.getParameter( "url" ) ;

URL url = new URL (a_Url);
String encoding = Base64Encoder.encode ("test:test");

HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.setRequestProperty  ("Authorization", "Basic " + encoding);
InputStream content = (InputStream)connection.getInputStream();
BufferedReader in   = 
    new BufferedReader (new InputStreamReader (content));
String line;
while ((line = in.readLine()) != null) {
    System.out.println(line);
}

%>
Run Code Online (Sandbox Code Playgroud)

java

9
推荐指数
2
解决办法
5万
查看次数

如何使用Datastax Java驱动程序的异步/批量写入功能

我打算使用Datastax Java驱动程序写入Cassandra ..我主要感兴趣的是Datastax java驱动程序Batch WritesAsycnhronous功能,但是我无法获得任何可以解释如何在我的下面使用Datastax的代码中加入这些功能的教程Java驱动程序..

/**
 * Performs an upsert of the specified attributes for the specified id.
 */
public void upsertAttributes(final String userId, final Map<String, String> attributes, final String columnFamily) {

    try {

        // make a sql here using the above input parameters.

        String sql = sqlPart1.toString()+sqlPart2.toString();

        DatastaxConnection.getInstance();
        PreparedStatement prepStatement = DatastaxConnection.getSession().prepare(sql);
        prepStatement.setConsistencyLevel(ConsistencyLevel.ONE);        

        BoundStatement query = prepStatement.bind(userId, attributes.values().toArray(new Object[attributes.size()]));

        DatastaxConnection.getSession().execute(query);

    } catch (InvalidQueryException e) {
        LOG.error("Invalid Query Exception in DatastaxClient::upsertAttributes "+e);
    } catch (Exception e) …
Run Code Online (Sandbox Code Playgroud)

java cassandra datastax-java-driver

8
推荐指数
2
解决办法
1万
查看次数