问题列表 - 第33350页

是否可以在没有HDFS的情况下以伪分布式操作运行Hadoop?

我正在探索在本地系统上运行hadoop应用程序的选项.

与许多应用程序一样,前几个版本应该能够在单个节点上运行,只要我们可以使用所有可用的CPU内核(是的,这与此问题相关).目前的限制是,在我们的生产系统中,我们有Java 1.5,因此我们将Hadoop 0.18.3作为最新版本(请参阅此问题).所以不幸的是我们还不能使用这个新功能.

第一个选项是在伪分布式模式下运行hadoop.基本上:创建一个完整的hadoop集群,其中的所有内容都在1个节点上运行.

这种形式的"缺点"是它还使用了完整的HDFS.这意味着为了处理输入数据,必须首先将其"上传"到本地存储的DFS ...上.因此,这会占用输入和输出数据的额外传输时间,并使用额外的磁盘空间.在我们保持单节点配置时,我想避免这两种情况.

所以我在想:是否可以覆盖"fs.hdfs.impl"设置并将其从"org.apache.hadoop.dfs.DistributedFileSystem"更改为(例如)"org.apache.hadoop.fs.LocalFileSystem" ?

如果这工作,"本地"hadoop集群(它只能由一个节点组成)可以使用现有文件而无需任何额外的存储要求,并且它可以更快地启动,因为不需要上传文件.我希望仍然有一个工作和任务跟踪器,也许还有一个名称节点来控制整个事情.

有人曾尝试过这个吗?它可以工作还是这个想法远远超出预期用途?

或者是否有更好的方法来获得相同的效果:没有HDFS的伪分布式操作?

感谢您的见解.


编辑2:

这是我使用bajafresh4life提供的答案为hadoop 0.18.3 conf/hadoop-site.xml创建的配置.

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!-- Put site-specific property overrides in this file. -->

<configuration>
  <property>
    <name>fs.default.name</name>
    <value>file:///</value>
  </property>

  <property>
    <name>mapred.job.tracker</name>
    <value>localhost:33301</value>
  </property>

  <property>
    <name>mapred.job.tracker.http.address</name>
    <value>localhost:33302</value>
    <description>
    The job tracker http server address and port the server will listen on.
    If the port is 0 then the server will start on a free port.
    </description>
  </property>

  <property> …
Run Code Online (Sandbox Code Playgroud)

hadoop mapreduce hdfs local-storage

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

如何通过c#代码为新共享文件夹上的所有用户设置权限?

如何通过c#代码为新共享文件夹上的所有用户设置权限?这是我添加共享文件夹的代码:

public static string sharedFolder()
{
    try
    {
        // create a directory
        Directory.CreateDirectory(@"C:\MyTestShare");
        // Create a ManagementClass object
        ManagementClass managementClass = new ManagementClass("Win32_Share");
        // Create ManagementBaseObjects for in and out parameters
        ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
        ManagementBaseObject outParams;
        // Set the input parameters
        inParams["Description"] = "My Files Share";
        inParams["Name"] = "My Files Share";
        inParams["Path"] = @"C:\MyTestShare";
        inParams["Type"] = 0x0; // Disk Drive
        // Invoke the method on the ManagementClass object
        //InvokeMethodOptions _invokeMethodOptions=new InvokeMethodOptions.InfiniteTimeout.h
        outParams = managementClass.InvokeMethod("Create", inParams,null);
        setPermissionsToShareFolder(inParams["Path"].ToString());
        // AddDirectorySecurity(inParams["Path"].ToString());
        // …
Run Code Online (Sandbox Code Playgroud)

c#

0
推荐指数
1
解决办法
5913
查看次数

基于文本的RPG命令解释器

我只是在玩一个基于文本的RPG,我想知道,命令解释器究竟是如何实现的,现在有更好的方法来实现类似的东西吗?很容易做出大量的if语句,但这似乎很麻烦,特别是考虑到大多数情况pick up the goldpick up gold具有相同效果的相同take gold.我确信这是一个非常深入的问题,我只想知道如何实现这样的解释器的一般概念.或者如果有一个开源游戏,有一个体面和有代表性的翻译,那将是完美的.

答案可以是语言独立的,但要尽量保持合理的东西,而不是prolog或golfscript等.我不确定该标记到底是什么.

interpreter

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

垃圾收集,我们应该依赖它吗?

在代码中,我们说:

using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString()))
{
    cn.Open();

    // Set all previous settings to inactive
    using (SqlCommand cmd = new SqlCommand("UPDATE tblSiteSettings SET isActive = 0", cn))
    {                            
        cmd.ExecuteNonQuery();
    }

    cn.Close();
}
Run Code Online (Sandbox Code Playgroud)

cn.close在技​​术上是不必要的,因为垃圾收集将为我们处理连接.

但是,我总是喜欢关闭它,不依赖于垃圾收集.这不好吗?浪费时间?或者考虑不依赖自动化的良好做法?

提前感谢您的想法和意见.我将此标记为社区维基,因为它可能是主观的.

c# garbage-collection

6
推荐指数
2
解决办法
682
查看次数

如何使用Reflection在IEnumerable <T>上调用System.Linq.Enumerable.Count <>?

我有一堆IEnumerable集合,确切的数量和类型经常更改(由于自动代码生成).

它看起来像这样:

public class MyCollections {
    public System.Collections.Generic.IEnumerable<SomeType> SomeTypeCollection;
    public System.Collections.Generic.IEnumerable<OtherType> OtherTypeCollection;
    ...
Run Code Online (Sandbox Code Playgroud)

在运行时,我想确定每个Type和它的计数,而不必在每次代码生成后重写代码.所以我正在寻找使用反射的通用方法.我正在寻找的结果是这样的:

MyType: 23
OtherType: 42
Run Code Online (Sandbox Code Playgroud)

我的问题是我无法想象如何正确调用Count方法.这是我到目前为止:

        // Handle to the Count method of System.Linq.Enumerable
        MethodInfo countMethodInfo = typeof(System.Linq.Enumerable).GetMethod("Count", new Type[] { typeof(IEnumerable<>) });

        PropertyInfo[] properties = typeof(MyCollections).GetProperties();
        foreach (PropertyInfo property in properties)
        {
            Type propertyType = property.PropertyType;
            if (propertyType.IsGenericType)
            {
                Type genericType = propertyType.GetGenericTypeDefinition();
                if (genericType == typeof(IEnumerable<>))
                {
                    // access the collection property
                    object collection = property.GetValue(someInstanceOfMyCollections, null);

                    // access the type of the generic collection …
Run Code Online (Sandbox Code Playgroud)

c# generics reflection collections ienumerable

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

如何使用UnitTest ++运行单个测试?

如何使用UnitTest ++运行单个测试?

我正在运行UnitTest ++.我的main功能如下:

int main()
{
   printf("diamond test v0.1 %s\n\n",TIMESTAMP);
   diamond::startup();
   UnitTest::RunAllTests();
   diamond::shutdown();
   printf("press any key to continue...");
   getc(stdin);
}
Run Code Online (Sandbox Code Playgroud)

对于调试我想写一些UnitTest::RunSingleTests("MyNewUnitTest");代替的东西UnitTest::RunAllTests();.UnitTest ++是否提供了这样的功能?如果是,那么语法是什么?

c++ unittest++

11
推荐指数
2
解决办法
3505
查看次数

如何在Java中返回标志和可选消息?

我想用Java编写一个方法来验证某些条件是否存在某些数据,并确认数据有效产生适当的错误消息.

问题是我们不能从一个方法返回多个东西,所以我想知道最佳解决方案是什么(在可读性和可维护性方面).

第一解决方案 很容易,但我们无法知道究竟是什么使检查失败:

boolean verifyLimits1(Set<Integer> values, int maxValue) {
    for (Integer value : values) {
        if (value > maxValue) {
            return false; // Out of limits
        }
    }
    return true; // All values are OK
}
Run Code Online (Sandbox Code Playgroud)

二解决方案.我们有消息,但我们正在以一种我们不应该使用的方式使用异常(此外,它应该是特定于域的已检查异常,过多的开销IMO):

void verifyLimits2(Set<Integer> values, int maxValue) {
    for (Integer value : values) {
        if (value > maxValue) {
            throw new IllegalArgumentException("The value " + value + " exceeds the maximum value");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

第三种方案.我们有一个详细的消息,但合同不干净:我们让客户端检查String是否为空(他需要读取javadoc).

String verifyLimits3(Set<Integer> values, int maxValue) { …
Run Code Online (Sandbox Code Playgroud)

java readability

3
推荐指数
2
解决办法
2008
查看次数

替代"Referer"标题

我使用了代码"request.getHeader("Referer");" 代码似乎工作正常.但最近我发现它在IE中不起作用.IE投掷无效.我现在对如何前进毫无头绪.有没有"Referer"标题的替代品可以获得以前的链接并在所有浏览器中正常工作?从上一个链接设置自定义标题对我来说不是一个可行的选择.所以有人请帮我解决这个问题.谢谢.

java jsp http http-headers

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

在Toad中显示输出参数的结果

我在Oracle中有一个存储过程,我在其中使用了一个out参数..我想知道如何在Toad中显示输出.

oracle toad plsql stored-procedures

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

测试视图助手

我目前正在研究用于生成iPhone特定HTML元标记的Rails插件.我正在尝试使用ActionView :: TestCase进行单元测试但仍然遇到相同的错误.请参阅下面的文件内容和错误.任何想法或帮助将不胜感激.

test_helper.rb中

require 'rubygems'
require 'test/unit'
require 'active_support'
require 'action_view'
require File.join(File.dirname(__FILE__), '..', 'lib', 'iphone_helper')
Run Code Online (Sandbox Code Playgroud)

iphone_test_helper.rb

require 'test_helper'

class IphoneHelperTest < ActionView::TestCase
  test 'br' do
    tag = tag('br')
    assert_tag_in tag, '<br />'
  end
end
Run Code Online (Sandbox Code Playgroud)

错误

RuntimeError: In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers
Run Code Online (Sandbox Code Playgroud)

iphone unit-testing ruby-on-rails helpers

13
推荐指数
1
解决办法
792
查看次数