MPI.net

2008-10-06

日本でも Windows HPC Server 2008 が発表されましたが
このクラスタノードで実行するアプリを書くためのライブラリとして
MPI.net (High-Performance C# Library for Message Passing) というライブラリが公開されていました

通常は C++ での開発となることが多いと思いますが
このライブラリを使うことで C# で Message Passing Interface を使って
Network Direct などのノード間通信を使いながらクラスタ計算が可能になる模様

詳しく試していませんがなかなかおもしろそうな予感です

MPI.net
http://www.osl.iu.edu/research/mpi.net/

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Admintech.jp のセミナー中に作ったコードをコマンドとして使えるように拡張しました

イベントログの内容を正規表現を使うことで
取り出したい内容をもったログだけを標準出力に吐きだせるようにしました

使い方としては、コマンド引数として /s:{イベントログのソース} "正規表現" を渡すと
指定したソース (Application や System) から正規表現にログの内容がマッチしたものを
まとめてCSVで出力するようになっています

また /n オプションを使うと、正規表現にマッチしなかったログだけを出力できます

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;

namespace EnvironmentManagement
{
    class Program
    {
        static int Main(string[] args)
        {
            Regex cmdHelp =
               new Regex("^/h", 
                 RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
            Regex cmdPositive = 
               new Regex("^/p", 
                 RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
            Regex cmdNegative = 
               new Regex("^/n", 
                 RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
            Regex cmdQuit = 
               new Regex("^/q", 
                 RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
            Regex cmdSource = 
               new Regex("^/s:\"?(?<source>.*)\"?", 
                 RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);

            bool quitMode = false;
            bool positiveMatch = true;
            string expression = String.Empty;
            string source = String.Empty;

            foreach (string param in args)
            {
                if (cmdHelp.IsMatch(param))
                {
                    ShowHelp();

                    return 0;
                }

                if (cmdPositive.IsMatch(param))
                {
                    positiveMatch = true;
                }
                else if (cmdNegative.IsMatch(param))
                {
                    positiveMatch = false;
                }
                else if (cmdQuit.IsMatch(param))
                {
                    quitMode = true;
                }
                else if (cmdSource.IsMatch(param))
                {
                    Match match = cmdSource.Match(param);

                    source = match.Groups["source"].Value;
                }
                else
                {
                    expression = param;
                }
            }

            if (!quitMode)
            {
                Console.WriteLine("EventLog Exporter with Regular Expressions");
                Console.WriteLine();
            }

            if (expression == string.Empty)
            {
                if (!quitMode) Console.Error.WriteLine("Please input regular expressions.");

                return 1;
            }
            else if (source == string.Empty)
            {
                if (!quitMode) Console.Error.WriteLine("Please input eventlog source name.");

                return 1;
            }

            try
            {
                ReadEventLogs(source, expression, positiveMatch);
            }
            catch (Exception e)
            {
                if (!quitMode)
                {
                    Console.Error.Write(e.Source);
                    Console.Error.Write(", ");
                    Console.Error.WriteLine(e.Message);
                }

                return 1;
            }

            return 0;
        }

        private static void ReadEventLogs(string source, string expression, bool positiveMatch)
        {
            EventLog logs = new EventLog(source);
            Regex regex = new Regex(expression, 
                 RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);

            OutputHeader();

            foreach (EventLogEntry entry in logs.Entries)
            {
                if (positiveMatch && regex.IsMatch(entry.Message))
                {
                    OutputLog(entry, source);
                }
                else if (!positiveMatch && !regex.IsMatch(entry.Message))
                {
                    OutputLog(entry, source);
                }
            }
        }

        private static void OutputHeader()
        {
            Console.Write("\"");
            Console.Write("Source");
            Console.Write("\",");

            Console.Write("\"");
            Console.Write("InstanceId");
            Console.Write("\",");

            Console.Write("\"");
            Console.Write("EntryType");
            Console.Write("\",");

            Console.Write("\"");
            Console.Write("Category");
            Console.Write("\",");

            Console.Write("\"");
            Console.Write("ApplicationSource");
            Console.Write("\",");

            Console.Write("\"");
            Console.Write("TimeGenerated");
            Console.Write("\",");

            Console.Write("\"");
            Console.Write("TimeWritten");
            Console.Write("\",");

            Console.Write("\"");
            Console.Write("MachineName");
            Console.Write("\",");

            Console.Write("\"");
            Console.Write("Username");
            Console.Write("\",");

            Console.Write("\"");
            Console.Write("Message");
            Console.Write("\"");

            Console.WriteLine();
        }

        private static void OutputLog(EventLogEntry entry, string source)
        {
            Console.Write("\"");
            Console.Write(source);
            Console.Write("\",");

            Console.Write("\"");
            Console.Write(entry.InstanceId.ToString());
            Console.Write("\",");

            Console.Write("\"");
            Console.Write(entry.EntryType.ToString());
            Console.Write("\",");

            Console.Write("\"");
            Console.Write(entry.Category);
            Console.Write("\",");

            Console.Write("\"");
            Console.Write(entry.Source);
            Console.Write("\",");

            Console.Write("\"");
            Console.Write(entry.TimeGenerated.ToString("s"));
            Console.Write("\",");

            Console.Write("\"");
            Console.Write(entry.TimeWritten.ToString("s"));
            Console.Write("\",");

            Console.Write("\"");
            Console.Write(entry.MachineName);
            Console.Write("\",");

            Console.Write("\"");
            Console.Write(entry.UserName);
            Console.Write("\",");

            Console.Write("\"");
            Console.Write(entry.Message.Replace("\"", "'"));
            Console.Write("\"");

            Console.WriteLine();
        }

        private static void ShowHelp()
        {
            Console.WriteLine("EventLog with regular expressions:");

            Console.WriteLine();

            Console.WriteLine(String.Format("{0} {1}", 
               System.IO.Path.GetFileNameWithoutExtension(Environment.GetCommandLineArgs()[0]), 
               "/h /p /n /q /s:{EventLogSource} \"{RegularExpression}\""));

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("\t/h\tShow help.");
            Console.WriteLine("\t/p\tIf regular expressoin is match, to EventLog export.");
            Console.WriteLine("\t/p\tIf regular expression is not match, to EventLog export.");
            Console.WriteLine("\t/q\tQuit mode.");
            Console.WriteLine("\t/s:{EventLogSource}\n\t\tExporting EventLog source name.");
            Console.WriteLine("\t\"{RegularExpression}\"\n\t\tSearch keyword");

            Console.WriteLine();
        }
    }
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

.NET Framework v3.5 では System.Management 名前空間を使って
WMI プロバイダ経由でいろいろなデータの取得や設定、また操作ができます。

その中で Win32_Process クラスを使って
プロセスの起動と終了を行うサンプルを作成してみました

using System;
using System.Collections.Generic;
using System.Management;
using System.Diagnostics;

namespace EnvironmentManagement
{
    class Program
    {
        static void Main(string[] args)
        {
            // calc.exe を実行する
            int processId = InvokeProcess("calc.exe");

            Console.ReadLine();

            // 指定したプロセスIDを終了する
            TerminateProcess(processId);

            Console.ReadLine();
        }

        // 引数に指定された実行ファイルを起動する
        private static int InvokeProcess(string executeFile)
        {
            // Win32 Process を扱うWMIプロバイダ クラスを取得する
            ManagementClass processClass = new ManagementClass("Win32_Process");
           
            // Create メソッドのパラメータを準備する
            ManagementBaseObject inParams = processClass.GetMethodParameters("Create");

            // Create メソッドのパラメータとして
            inParams["CommandLine"] = executeFile;

            // Create メソッドをパラメータ付きで呼び出す
            ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);

            // メソッドの実行結果を表示する
            Console.WriteLine("メソッド実行結果: " + outParams["returnValue"]);
            Console.WriteLine("プロセスID: " + outParams["processId"]);
           
            return Int32.Parse(outParams["processId"].ToString());
        }

        // 指定したプロセスを終了させる
        private static void TerminateProcess(int processId)
        {
            ManagementScope scope = new ManagementScope(@"\\.\ROOT\CIMV2");
            scope.Connect();

            // 指定したプロセスIDを持つプロセスをクエリする
            ObjectQuery query =
                new ObjectQuery(String.Format(@"SELECT * FROM Win32_Process WHERE ProcessID = {0}", processId));

            ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
            ManagementObjectCollection col = searcher.Get();

            // クエリの結果を取得する
            foreach (ManagementObject obj in col)
            {
                // プロセスを終了させる Terminate メソッドの引数を設定する
                ManagementBaseObject inParams = obj.GetMethodParameters("Terminate");
                inParams["Reason"] = 0;

                // クエリで取得したプロセス インスタンス オブジェクトの Terminate メソッドを呼び出し、プロセスを終了する
                obj.InvokeMethod("Terminate", inParams, null);
            }
        }
    }
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Do Less. Get More. Develop on SharePoint ということで
MOSS に関連するリソースがまとまっているサイトが公開されていました

さりげなく Silverlight が使われていたりとなかなかセンスのいい感じにまとまってます

http://www.microsoft.com/click/SharePointDeveloper/default.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Microsoft から Database, Filesystem, RSS に対応したデータ同期用フレームワークのCTPがでていました

どうやらこのフレームワークを使うと、バージョンや更新時間などのメタデータを元に、
データソースの同期を簡単に実装できるようになっている模様です

http://www.microsoft.com/downloads/details.aspx?FamilyID=35E8F16E-AAA4-4919-8B3C-1CE4EA1F6552&displaylang=en

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

MSN Search SDK Beta

2006-01-15

MSN Search Web Service SDK Beta v0.60 が公開されていました

やや詳細不明ではありますが
どうやら MSN Search の結果を Web Service で取り込み
それを使うための SDK みたいですね

ドキュメントやサンプルコードも含まれている模様です

http://www.microsoft.com/downloads/details.aspx?familyid=C271309B-02DE-42A7-B23E-E19F68667197&displaylang=en

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

"Visual Basic .NET 2003 および Visual Basic .NET 2002 で Dsofile.dll を使用すると Office がなくても Office ドキュメントのプロパティを編集できる"
と題したKBが公開されていました

このKBでは C++ で作られたサンプルActiveX コンポーネントが紹介されていて
DLLを経由してOLE構造化ストレージのプロパティにアクセスする方法が書かれています

コンポーネントは再配布可能とのことですので
あのメタデータを操作したかった方には朗報ではないでしょうか

http://support.microsoft.com/default.aspx?scid=kb;ja;224351

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Acrylic October 2005 CTP に XAML Exporter がでました

Avalon のインターフェイスデザイナになりそうな Acrylic ですが
ついに XAML Exporter がでたことでいろいろ試せそうですね

http://www.microsoft.com/downloads/details.aspx?FamilyID=286D50B8-4D6F-460A-A83B-D4D0ED2EBF39&displaylang=en

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

C# が日本工業規格 (JIS) に JIS X 3015 として制定されました
http://www.microsoft.com/japan/presspass/detail.aspx?newsid=2236
http://www.exconn.net/Blogs/team01/archive/2005/03/22/292.aspx

すでに ECMA や ISO/ETC でも標準化されてますが
これによってさらに普及していくんでしょうかね~

また C#?の MVP たちのコメントも掲載されています

http://www.exconn.net/Blogs/team00/archive/2005/03/22/293.aspx
http://www.microsoft.com/japan/msdn/vcsharp/BeSharpCsharp/daisuki.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

WiX

2005-03-17

Visual Studio.NET では定型のインストーラしか作成できませんが
こちらは XML でインストーラを定義することによって
かなり自由にインストーラを生成することが可能なようです

かわりに Windows Installer を相当知っていないとダメとのことですけど...
でも MSP まで作れるというのが魅力的ですな

http://sourceforge.net/projects/wix/
http://www.ailight.jp/blog/sha256/archive/2005/03/14/4950.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Microsoft Press から コードコンプリート 第2版 が発売されるそうです

サンプルコードが C# などになっているほかに
オブジェクト指向に関係する章やリファクタリングの章が追加されているそうです

本質はそのままに最近のトレンドを取り込んでいるという感じでしょうか?
ぜひ読んでみたいですね

http://www.microsoft.com/japan/info/press/

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

WSE 2.0 SP3 がでていました

日本ではあまり話題に上っていない気もしますが
XMLベースの相互運用環境として着実に進化してますね

http://www.microsoft.com/downloads/details.aspx?FamilyID=1ba1f631-c3e7-420a-bc1e-ef18bab66122

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Eclipse で C#

2004-12-11

おぎわらさん情報なのですが
Eclipse 用 C# Plugin が提供されているのですね

Windows 環境以外でも C# Plugin は動く模様なので
Mono と組み合わせれば UNIX 環境で完結した開発もC#で可能と...

http://www.atmarkit.co.jp/fdotnet/tools/eclipse/eclipse_01.html

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

MSXML 3.0 SP5 が公開されました

内容は

  • Server-safe HTTP アクセス
  • XSLT (XSL Transformations) および XPath (XML Path Language) の完全実装
  • W3C (World Wide Web Consortium) の標準および OASIS Test Suite への準拠がさらに高くなった新しい SAX2 ヘルパー クラスを含め、SAX2 (Simple API for XML) 実装に対する変更
  • とのことです

    http://www.microsoft.com/downloads/details.aspx?displaylang=ja&FamilyID=4a3ad088-a893-4f0b-a932-5e024e74519f

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    エクスプローラでファイルのファイルサイズを見ると
    いい感じに省略されて見やすくなっていますよね

    単純に1024単位で桁を切っていくだけでは見やすくならないので
    なんとか適度な省略方法を探してみたり...

    どういう基準で桁をまとめてるんだろう

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5